Selecting objects within a polyline

Discussion in 'AutoCAD' started by Greg McLandsborough, Dec 2, 2004.

  1. What's the best way to select all the entities within a polyline in lisp.
    I've
    tried getting the co-ordinates and converting them to a point list and using
    ssget. An comments appreciated

    Cheers

    Greg
     
    Greg McLandsborough, Dec 2, 2004
    #1
  2. Greg McLandsborough

    Fatfreek Guest

    Greg
    This is not be the best way but it has worked for one of my apps. There are
    other routines out there that use the vertices of the polylines and that
    wouldn't work for me because of all the radii (bulges) in my types of polys.
    Basically this routine merely draws a bunch of points along the polyline
    using the Measure command. The increment that worked for me is 0.25 which
    you may want to adjust or make it some input variable. I also use "cp"
    (which also selects the poly itself) so you may wish to use "wp". The
    container variable is EntsWithin .

    Have fun.
    Len Miller

    (defun c:Encircle
    ;; This routine is designed to pick a closed polyline boundary,
    ;; then select all entities within,
    (/ ThisPt PtData TypeEnt
    PointsIncr PtCount PtDex PtCoords
    PtList FirstCP SecondCP BoundEnt
    ThisEnt EntData ColorEnt LayerEnt
    PtEnts
    )
    (princ "Select a Closed Poly [Must be ALL visible!]\n")
    (setq FirstCP (getpoint "\nFirst crossing point"))
    (setq SecondCP (getpoint "\nSecond crossing point"))
    (setq BoundEnt (ssget "c"
    FirstCP
    SecondCP
    '((-4 . "<or")
    (0 . "POLYLINE")
    (0 . "LWPOLYLINE")
    (-4 . "or>")
    )
    )
    )
    (if (= BoundEnt nil)
    (progn
    (alert "Polyline not found at crossing. Check it out.")
    (Quit)
    )
    )
    (setq ThisEnt (ssname BoundEnt 0))
    (setq EntData (entget ThisEnt))
    (setq ColorEnt (cdr (assoc 62 EntData)))
    (setq LayerEnt (cdr (assoc 8 EntData)))
    (setq TypeEnt (cdr (assoc 0 EntData)))
    (if (= TextHt_GL nil)
    (setq PointsIncr 0.25)
    (setq PointsIncr (* TextHt_GL 4))
    )
    (command "_.measure" BoundEnt PointsIncr)
    (setq PtCount (sslength
    (setq PtEnts (ssget "x" '((0 . "POINT"))))
    )
    )
    (setq PtDex 0
    PtList nil
    TextWithin
    nil
    )
    (repeat PtCount
    (setq ThisPt (ssname PtEnts PtDex))
    (setq PtData (entget ThisPt))
    (setq PtCoords (cdr (assoc 10 PtData)))
    (setq PtList (cons PtCoords PtList))
    (setq PtDex (1+ PtDex))
    ) ;_end repeat
    (command "_.erase"
    (ssget "x"
    '(
    (0 . "POINT")
    )
    )
    ""
    )
    (setq EntsWithin (ssget "cp" PtList))
    )

    I've trimmed some stuff out and left it mostly generic but I'd be careful
    until.
     
    Fatfreek, Dec 2, 2004
    #2
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.