Which closed LWpolyline is largest?

Discussion in 'AutoCAD' started by Fatfreek, Nov 21, 2004.

  1. Fatfreek

    Fatfreek Guest

    In one of my routines a set of enclosed LWpolylines are created. One of
    them encloses all the others and I would like to know (automatically, of
    course) which of them it is. I suppose I could place them into a list,
    cycle through that list, getting the area of each, one by one. Whichever
    has the larger area would be the boundary of them all.

    Is there a more elegant way?

    Len Miller
     
    Fatfreek, Nov 21, 2004
    #1
  2. Fatfreek

    Fatfreek Guest

    I'm supposing there's no elegant way so for those other bunglers like me
    (since there have been no responses till now), here's what I got to work:

    (setq WithinDex 0
    BigArea 0
    AreasList nil
    ObjEnt nil
    ObjArea nil
    )
    (repeat (sslength PolysWithin)
    (setq EntName (ssname PolysWithin WithinDex))
    (setq
    ObjArea (vlax-curve-getArea (vlax-ename->vla-object EntName))
    )
    (setq AreasList
    (cons
    (list EntName ObjArea)
    AreasList
    )
    )
    (if (> ObjArea BigArea)
    (setq BigArea ObjArea
    BigEnt EntName
    )
    )
    (setq WithinDex (1+ WithinDex))
    )
     
    Fatfreek, Nov 22, 2004
    #2
  3. Fatfreek

    Jürg Menzi Guest

    Hi Len

    Code:
    (defun MeGetBigArea (Sst / CurEnt TmpAre TmpLst)
    (while (setq CurEnt (ssname Sst 0))
    (setq TmpAre (vlax-curve-getArea (vlax-ename->vla-object CurEnt)))
    (if (> TmpAre (car TmpLst)) (setq TmpLst (cons TmpAre CurEnt)))
    (ssdel CurEnt Sst)
    )
    (cdr TmpLst)
    )
    
    Cheers
     
    Jürg Menzi, Nov 22, 2004
    #3
  4. Fatfreek

    Fatfreek Guest

    Thanks, Juerg. It works great as I suspected it would.
    Len Miller
     
    Fatfreek, Nov 22, 2004
    #4
  5. Fatfreek

    Jürg Menzi Guest

    Hi Len

    <g> you are welcome...¦-)

    Cheers
     
    Jürg Menzi, Nov 23, 2004
    #5
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.