How can I determine the size of the drawing.

Discussion in 'AutoCAD' started by Alejandro, Oct 23, 2004.

  1. Alejandro

    Alejandro Guest

    I am currently iterating through all the items in the ModelSpace and
    finding the largest and smallest; in essence finding the corners of the
    drawing (see code).

    For Each entry In ThisDrawing.ModelSpace
    entry.GetBoundingBox pLeft, pRight
    If pLeft(0) < lMinW Then lMinW = pLeft(0)
    If pLeft(1) < lMinH Then lMinH = pLeft(1)
    If pRight(0) > rMaxW Then rMaxW = pRight(0)
    If pRight(1) > rMaxH Then rMaxH = pRight(1)
    Next

    However, this may not be the best nor most efficient way of going about
    this, and I am open to suggestions. My problem is that my limits are
    larger than the actual drawing. Are there some hidden elements in the
    modelspace that can thow off my calculations?

    I'm definitely thinking that I just want the smallest rectangle that the
    drawing fits in, a la ZoomExtents. Does anyone have any ideas to help
    me out?

    Thanks,

    Alex
     
    Alejandro, Oct 23, 2004
    #1
  2. Zoom extents then check the value of EXTMIN and EXTMAX.
     
    Frank Oquendo, Oct 23, 2004
    #2
  3. Alejandro

    Alejandro Guest

    Thanks, that worked great. For those of you interested in how to do this:

    Dim coorR As Variant
    Dim coorL As Variant
    coorL = ThisDrawing.GetVariable("extmin")
    coorR = ThisDrawing.GetVariable("extmax")
    dwgHeight = Abs(coorR(1) - coorL(1))
    dwgWidth = Abs(coorR(0) - coorL(0))

    Thanks again for the tip.

    Alex
     
    Alejandro, Oct 26, 2004
    #3
  4. You need to perform a Zoom Extents to get updated coordinates. Without the
    zoom you cannot rely on the results.

    --
    R. Robert Bell


    Thanks, that worked great. For those of you interested in how to do this:

    Dim coorR As Variant
    Dim coorL As Variant
    coorL = ThisDrawing.GetVariable("extmin")
    coorR = ThisDrawing.GetVariable("extmax")
    dwgHeight = Abs(coorR(1) - coorL(1))
    dwgWidth = Abs(coorR(0) - coorL(0))

    Thanks again for the tip.

    Alex
     
    R. Robert Bell, Oct 26, 2004
    #4
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.