Finding a closed polyline within a closed polyline

Discussion in 'AutoCAD' started by Bill DeShawn, Jul 21, 2004.

  1. Bill DeShawn

    Bill DeShawn Guest

    Does somebody have a routine that will locate instances of a closed POLYLINE
    within a closed polyline. They may be LWPOLYLINES. I don't think any of
    them are 3DPOLYs.
     
    Bill DeShawn, Jul 21, 2004
    #1
    1. Advertisements

  2. Bill DeShawn

    Jim Claypool Guest

    (defun c:chkpline ( / ename)
    ;Select the polyline
    (while (not (setq ename (entsel "\nSelect the polyline: "))))
    (setq ename (car ename))
    ;get a list of points
    (process_pline)
    ;zoom to the extents of the polyline
    (command ".zoom" "w" (car ptlist) (last ptlist))
    ;zoom out to be sure the polyline is on the screen
    (command ".zoom" "0.75x")
    ;look for closed polylines within the selected one.
    (setq ss (ssget "wp" ptlist '((0 . "POLYLINE,LWPOLYLINE")(70 . 1))))
    ;print the result
    (if ss
    (princ (strcat "\n" (itoa (sslength ss)) " Closed polylines found"))
    (princ "\nNo closed polylines found")
    )
    ;(setq ptlist nil)
    (princ)
    )

    (defun process_pline ( / ent1 en pt ename1)
    (setq ent1 (entget ename))
    (setq en (cdr (assoc 0 ent1)))
    (setq ptlist '())
    (cond
    ((= en "LWPOLYLINE")
    (foreach pt ent1
    (if (equal (car pt) 10)
    (setq ptlist (cons (cdr pt) ptlist))
    )
    )
    )
    ((= en "POLYLINE")
    (setq ename1 (entnext ename) entl (entget ename1) en (cdr (assoc 0 entl))
    ptlist '())
    (while (= en "VERTEX")
    (setq pt (cdr (assoc 10 entl)) ptlist (cons pt ptlist))
    (setq ename1 (entnext ename1) entl (entget ename1) en (cdr (assoc 0
    entl)))
    )
    )
    )
    (if ptlist (setq ptlist (reverse ptlist)))
    (princ)
    );end defun process_pline
     
    Jim Claypool, Jul 21, 2004
    #2
    1. Advertisements

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.