Lisp Routine Running Slowly

Lisp Routine Running Slowly

julie.pomeroyP5QW5
Explorer Explorer
2,707 Views
14 Replies
Message 1 of 15

Lisp Routine Running Slowly

julie.pomeroyP5QW5
Explorer
Explorer

I have a lisp routine that checks for overlaps and gaps with polylines, and will highlight (changes the object's color to yellow) the polylines that need to be corrected.  When using this routine in AutoCAD 2014 or 2015, it could check 350+ polylines in approximately 30 seconds.  When I run the routine in AutoCAD 2016, it takes about 12 minutes to run.  Suggestions, please!!   

0 Likes
2,708 Views
14 Replies
Replies (14)
Message 2 of 15

john.uhden
Mentor
Mentor

I suggest that you post the code so we can inspect it.  Even 30 seconds sounds excessive.

John F. Uhden

0 Likes
Message 3 of 15

julie.pomeroyP5QW5
Explorer
Explorer

Please see the attached lisp file.

 

Thanks!

0 Likes
Message 4 of 15

ВeekeeCZ
Consultant
Consultant

Would you post that test drawing?

 

BTW Unfortunately it's known that newer versions are slower, but I hope not that much.

 

Some power users says that '12 is the best year, then..

0 Likes
Message 5 of 15

julie.pomeroyP5QW5
Explorer
Explorer

Yes, I agree about 2012.  Unfortunately, the company uses the latest.

 

Attached is the DWG file.

 

Thanks!

0 Likes
Message 6 of 15

ВeekeeCZ
Consultant
Consultant

Xeon 3,5 GHz

My C3D 2016 as acad 2'05 (hw on, 2'20 hw off)

My C3D 2017 as acad 2'13 (hw on)

 

i7 3,4 GHz

Colleges's 2012 vanilla 0'25 (hw off)

Colleges's C3D 2016 as acad 2'15 (hw off)

 

0 Likes
Message 7 of 15

julie.pomeroyP5QW5
Explorer
Explorer

Interesting results.  A co-worker tested in 2015 and it took about 30 seconds. 

0 Likes
Message 8 of 15

john.uhden
Mentor
Mentor

Please don't think I am picking on you.  i just want you to learn.

 

Your get_pline_vertex function is so slow that it's pathetic.  My laptop is in such bad shape that it can't run for more than about 6 minutes before just turning itself off.

 

I tried my timer function on a very busy LWPOLYLINE for a only a hundred iterations, and it never finished before my laptop turned off.

 

Meanwhile, my VertList function (below) completed the same test in 2.25 seconds.  There are probably even faster functions out there, like anything that @Kent1Cooper would build using (vl-remove-if-not).  Start by understanding that the append function is very slow for adding one item at a time to a list.  'Tis much better to cons items and reverse the completed list.  (Gotta post this before my laptop dies again).

 

;; HOLD YOUR HORSES!
;; Doug Broad's function (c. 9-19-04) is way better!
;; It was called "2dpoints"
;; Added as replacement (11-21-04)
(defun @cv_double_up (flatlist);DCB04
  (if flatlist
    (cons
      (cons
        (car flatlist)
        (cons (cadr flatlist) nil)
      )
      (@cv_double_up (cddr flatlist))
    )
  )
)
;; Based on Doug's revelation, here's my 3Dversion:
;; Added as replacement (11-21-04)
(defun @cv_triple_up (flatlist);DCB04
  (if flatlist
    (cons
      (cons
        (car flatlist)
        (cons
          (cadr flatlist)
          (cons (caddr flatlist) nil)
        )
      )
      (@cv_triple_up (cdddr flatlist))
    )
  )
)

(defun VertList (e / Obj ObjName Vlist)
  (and
    (or
      (= (type e) 'ENAME)
      (prompt "\nInput value is not an entity.")
    )
    (setq Obj (vlax-ename->vla-object e))
    (setq ObjName (vlax-get Obj 'ObjectName))
    (cond
      ((= ObjName "AcDbPolyline")
        (setq Vlist (@cv_double_up (vlax-get Obj 'Coordinates)))
      )
      ((wcmatch ObjName "*Polyline")
        (setq Vlist (@cv_triple_up (vlax-get Obj 'Coordinates)))
     )
     (1 (prompt "\nObject provided is not a polyline."))
   )
 )
 Vlist
)

John F. Uhden

0 Likes
Message 9 of 15

marko_ribar
Advisor
Advisor

You can try this, based on John's posted example and on my function for checking of point inside polygon... I don't know if with my function it'll go faster, but it's more reliable than (ssget "_WP" ptlist '((0 . "POINT"))) as it should operate and if selection isn't on visible portion of active CAD screen interface...

 

;;code for review

(defun c:hov (/ BCOUNT CTR ENTL ENTN H_CTR OLD_OSMODE OLD_PDMODE PT_LIST SS SS2
                newerr OLDERR)
  (setvar "cmdecho" 0)
  (command "_.undo" "_g")

  (defun newerr (MSG)
    (if (not (member MSG '("Function cancelled" "quit / exit abort")))
      (princ (strcat "\nError: " MSG))
    )
    (if afm_overlay_loaded (AfmResumeReactor))
    (command "_.undo" "_end")
    (setq *error* OLDERR)
    (princ)
  )
  (setq OLDERR *error* *error* newerr
        OLD_OSMODE (getvar "osmode")
        OLD_PDMODE (getvar "pdmode")
  )
  (setvar "osmode" 0)
  (setvar "pdmode" 0)

  (if afm_overlay_loaded (AfmSuspendReactor))

  (princ "\nCheck Crossing Polylines, Hit Return for ALL")
  (if (not (setq SS (ssget '((0 . "*POLYLINE")))))
    (setq SS (ssget "x" '((0 . "*POLYLINE"))))
  )

  (if (not SS) (exit))
  (command "_.zoom" "_e")

  (setq CTR   0
        H_CTR 0
  )
  (repeat (sslength SS)
    (setq ENTN    (ssname SS CTR)
          ENTL    (entget ENTN)
          PT_LIST (get_pline_vertex ENTN)
          CTR     (1+ CTR)
          SS2     (ssget "cp" PT_LIST (list (cons 0 "*POLYLINE") (assoc 8 ENTL)))
    )
    (redraw ENTN 3)
    (if SS2 (progn
      (setq SS2 (ssdel ENTN SS2))
      (if (> (sslength SS2) 0)
        (highlight_overlapping PT_LIST SS2)
      )
    ))
    (redraw ENTN 4)
    (chewc "Polylines     ")
  )
  (command "_.zoom" "_p")
  (alert (strcat "Highlight Overlapping Polylines Program Complete.\n\n"
                 (itoa H_CTR)" Polylines Highlighted"
         )
  )

  (setvar "osmode" OLD_OSMODE)
  (setvar "pdmode" OLD_PDMODE)
  (if afm_overlay_loaded (AfmResumeReactor))
  (command "_.undo" "_end")
  (setq *error* OLDERR)
  (princ)
)
;;------------------------------------------------------------------------------
;Global:H_CTR
(defun highlight_overlapping (PT_LIST SS / CTR ENTL ENTN FLAG1 PT)
  (setq CTR 0)
  (repeat (sslength SS)
    (setq ENTN (ssname SS CTR))
    (foreach PT (get_pline_vertex ENTN)
      (if (is_inside PT PT_LIST)
        (setq FLAG1 t)
      )
    )
    (if FLAG1 (progn
      (setq FLAG1 nil
            ENTL  (entget ENTN)
            H_CTR (1+ H_CTR)
      )
      (if (assoc 62 ENTL)
        (setq ENTL (subst (cons 62 2) (assoc 62 ENTL) ENTL))
        (setq ENTL (append ENTL (list (cons 62 2))))
      )
      (entmod ENTL)
    ))
    (setq CTR (1+ CTR))
  )
)
;;------------------------------------------------------------------------------

;; HOLD YOUR HORSES!
;; Doug Broad's function (c. 9-19-04) is way better!
;; It was called "2dpoints"
;; Added as replacement (11-21-04)
(defun @cv_double_up (flatlist);DCB04
  (if flatlist
    (cons
      (cons
        (car flatlist)
        (cons (cadr flatlist) nil)
      )
      (@cv_double_up (cddr flatlist))
    )
  )
)
;; Based on Doug's revelation, here's my 3Dversion:
;; Added as replacement (11-21-04)
(defun @cv_triple_up (flatlist);DCB04
  (if flatlist
    (cons
      (cons
        (car flatlist)
        (cons
          (cadr flatlist)
          (cons (caddr flatlist) nil)
        )
      )
      (@cv_triple_up (cdddr flatlist))
    )
  )
)

(defun get_pline_vertex (e / Obj ObjName Vlist)
  (vl-load-com)
  (and
    (or
      (= (type e) 'ENAME)
      (prompt "\nInput value is not an entity.")
    )
    (setq Obj (vlax-ename->vla-object e))
    (setq ObjName (vlax-get Obj 'ObjectName))
    (cond
      ( (= ObjName "AcDbPolyline")
        (setq Vlist (@cv_double_up (vlax-get Obj 'Coordinates)))
        (setq Vlist (mapcar '(lambda ( x ) (trans (list (car x) (cadr x) (vlax-get Obj 'Elevation)) e 1)) Vlist))
      )
      ( (= ObjName "AcDb2dPolyline")
        (setq Vlist (@cv_triple_up (vlax-get Obj 'Coordinates)))
        (setq Vlist (mapcar '(lambda ( x ) (trans (list (car x) (cadr x) (vlax-get Obj 'Elevation)) e 1)) Vlist))
      )
      ( (= ObjName "AcDb3dPolyline")
        (setq Vlist (@cv_triple_up (vlax-get Obj 'Coordinates)))
        (setq Vlist (mapcar '(lambda ( x ) (trans x 0 1)) Vlist))
      )
      (t (prompt "\nObject provided is not a polyline."))
    )
  )
  Vlist
)

;|
(defun get_pline_vertex (ENTN / ENTL N VERTEX_LIST)
  (setq ENTL (entget ENTN))
  (if (= "POLYLINE" (cdr (assoc 0 ENTL)))
    (while (= "VERTEX" (cdr (assoc 0 (setq ENTL (entget (entnext ENTN))))))
      (setq VERTEX_LIST (append VERTEX_LIST (list (cdr (assoc 10 ENTL))))
            ENTN        (cdr (assoc -1 ENTL))
      )
    )
    (foreach N ENTL
      (if (= 10 (car N))
        (setq VERTEX_LIST (append (list (cdr N)) VERTEX_LIST))
      )
    )
  )
  VERTEX_LIST
)
|;

;;------------------------------------------------------------------------------

(defun is_inside ( pt ptlst / trianglst ptinsidetriangle-p trl )

  (defun trianglst ( ptlst / unique LM:ListClockwise-p clockwise-p l p1 p2 p3 trl )

    (defun unique ( l )
      (if l (cons (car l) (unique (vl-remove-if (function (lambda ( x ) (equal x (car l) 1e-6))) l))))
    )

    ;; List Clockwise-p - Lee Mac
    ;; Returns T if the point list is clockwise oriented

    (defun LM:ListClockwise-p ( lst )
      (minusp
        (apply '+
          (mapcar
            (function
              (lambda ( a b )
                (- (* (car b) (cadr a)) (* (car a) (cadr b)))
              )
            )
            lst (cons (last lst) lst)
          )
        )
      )
    )

    (defun clockwise-p ( p1 p2 p3 )
      (< (* (- (car  p2) (car  p1)) (- (cadr p3) (cadr p1)))
         (* (- (cadr p2) (cadr p1)) (- (car  p3) (car  p1)))
      )
    )

    (setq l ptlst)
    (while (> (length ptlst) 3)
      (setq p1 (car ptlst) p2 (cadr ptlst) p3 (caddr ptlst))
      (cond
        ( (LM:ListClockwise-p ptlst)
          (if
            (and
              (clockwise-p p1 p2 p3)
              (= (length (unique (vl-remove nil (mapcar (function (lambda ( a b ) (inters p1 p2 a b))) l (cdr (reverse (cons (car l) (reverse l)))))))) 2)
              (= (length (unique (vl-remove nil (mapcar (function (lambda ( a b ) (inters p2 p3 a b))) l (cdr (reverse (cons (car l) (reverse l)))))))) 2)
              (= (length (unique (vl-remove nil (mapcar (function (lambda ( a b ) (inters p3 p1 a b))) l (cdr (reverse (cons (car l) (reverse l)))))))) 2)
            )
            (progn
              (setq trl (cons (list p1 p2 p3) trl))
              (setq ptlst (vl-remove p2 ptlst))
              (setq ptlst (cdr (reverse (cons (car ptlst) (reverse ptlst)))))
            )
            (setq ptlst (cdr (reverse (cons (car ptlst) (reverse ptlst)))))
          )
        )
        ( (not (LM:ListClockwise-p ptlst))
          (if
            (and
              (not (clockwise-p p1 p2 p3))
              (= (length (unique (vl-remove nil (mapcar (function (lambda ( a b ) (inters p1 p2 a b))) l (cdr (reverse (cons (car l) (reverse l)))))))) 2)
              (= (length (unique (vl-remove nil (mapcar (function (lambda ( a b ) (inters p2 p3 a b))) l (cdr (reverse (cons (car l) (reverse l)))))))) 2)
              (= (length (unique (vl-remove nil (mapcar (function (lambda ( a b ) (inters p3 p1 a b))) l (cdr (reverse (cons (car l) (reverse l)))))))) 2)
            )
            (progn
              (setq trl (cons (list p1 p2 p3) trl))
              (setq ptlst (vl-remove p2 ptlst))
              (setq ptlst (cdr (reverse (cons (car ptlst) (reverse ptlst)))))
            )
            (setq ptlst (cdr (reverse (cons (car ptlst) (reverse ptlst)))))
          )
        )
      )
    )
    (setq trl (cons (list (car ptlst) (cadr ptlst) (caddr ptlst)) trl))
    trl
  )

  (defun ptinsidetriangle-p ( pt p1 p2 p3 )
    (and
      (not
        (or
          (inters pt p1 p2 p3)
          (inters pt p2 p1 p3)
          (inters pt p3 p1 p2)
        )
      )
      (not
        (or
          (> (+ (distance pt p1) (distance pt p2)) (+ (distance p3 p1) (distance p3 p2)))
          (> (+ (distance pt p2) (distance pt p3)) (+ (distance p1 p2) (distance p1 p3)))
          (> (+ (distance pt p3) (distance pt p1)) (+ (distance p2 p3) (distance p2 p1)))
        )
      )
    )
  )

  (setq trl (trianglst ptlst))
  (vl-some (function (lambda ( x ) (ptinsidetriangle-p pt (car x) (cadr x) (caddr x)))) trl)
)

;|
(defun is_inside (PT PT_LIST / ENTN FLAG1 SS)
  (command "_.point" PT)
  (setq ENTN (entlast))
  (if (setq SS (ssget "wp" PT_LIST '((0 . "POINT"))))
    (if (ssmemb ENTN SS)
      (setq FLAG1 t)
    )
  )
  (entdel ENTN)
  FLAG1
)
|;

;;;-----------------------------------------------------------------------------
(defun chewc (phrase)
  (if (not bcount) (setq bcount 0))
  (setq BCOUNT (1+ BCOUNT))
  (princ
    (Strcat "\rProcessing [" (rtos BCOUNT 2 0) "] " phrase)
  )
  (princ)
)
;;;-----------------------------------------------------------------------------
;(princ "\npline")
(princ "\nHighlight Overlapping Polylines Utility loaded.  Type HOV to execute.")
(princ)

P.S. I haven't checked for localization of variables and error handler functionality... Defined functions are out of the scope of main function and are global when routine loads...

 

HTH., M.R.

Marko Ribar, d.i.a. (graduated engineer of architecture)
0 Likes
Message 10 of 15

john.uhden
Mentor
Mentor

@marko_ribar

 

Here is my ancient and well worn @inside function, complete with remarks.

It is a function internal to my QuickArea command function to label the area of polylines just by picking any point inside.

 

I timed it on a 29 vertex LWPoly with plenty of inward and outward bulges at 2.70 sec. for 1000 iterations.

 

Unless I am mistaken, Lee Mac's IS_INSIDE function does not deal with bulged segments.

When I ran his function I got:

Command: (is_inside p pts) TRIANGLST

I don't know if that is equal to T (as in true) or what.

 

I have not studied or tested the rest of the OP's code as I was looking for just obvious speed improvements.

 

  (defun @Inside (PIQ Object / Closest Start End Param P
                               a1 a2 Defl @2D @Bulge)
    ;;               "LOOK, MA'... NO RAYS!"
    ;; @Inside.lsp v1.0 (09-15-03) John F. Uhden, Cadlantic.
    ;; v2.0 Revised (09-17-03) - See notes below.
    ;; v3.0 Revised (09-20-03) - See notes below.
    ;; Function to determine whether a point is inside the boundary
    ;; of a closed curve.
    ;; It employs the theorem that the sum of the deflections of a
    ;; point inside the curve should equal 360°, and if outside 0°
    ;; (both absolute values).
    ;; The results with Ellipses were fairly rough, and the results
    ;; with a Spline were very rough, thus the fuzz factor of 2.
    ;;
    ;; Arguments:
    ;;   PIQ    - Point to test (2D or 3D point as a list in UCS)
    ;;   Object - Curve to test (Ename or VLA-Object)
    ;;
    ;; Returns:
    ;;   T   (if the PIQ is inside the curve)
    ;;   nil (if either the arguments are invalid,
    ;;       or the PIQ is on or outside the curve)
    ;;
    ;; NOTES:
    ;;   Requires one or another version of the @delta function,
    ;;     such as included here.
    ;;   It will not work well with self-intersecting (overlapping)
    ;;     bulged polyline segments.
    ;;   Curves can be CIRCLEs, ELLIPSEs, LWPOLYLINEs, POLYLINES,
    ;;     SPLINEs, and maybe even more.
    ;;   Thanks already to Doug Broad for finding bugs.
    (setq Sample 0.5) ; this is better for bulged polylines.
    ;;   Sure, you could decrease the sampling from 0.5 to say 0.1,
    ;;     but it will only slow down the process and still not
    ;;     guarantee success with overlapping bulged segments.
    ;;   DO NOT change the sampling value to anything that is
    ;;     greater than 1 or not evenly divisible into 1, as you
    ;;     would not be sampling vertices.
    ;;   (09-17-03) Found that cusps brought back inside the figure
    ;;     yield a total deflection of (* pi 2), so changed evaluation
    ;;     to see if deflection was greater than 4, which is
    ;;     equivalent to a fuzz factor of 2.28 from (* pi 2).
    (vl-load-com)
    (or (= (type @delta) 'SUBR)
      (defun @delta (a1 a2)
        (cond
          ((> a1 (+ a2 pi))
            (+ a2 pi pi (- a1))
          )
          ((> a2 (+ a1 pi))
            (- a2 a1 pi pi)
          )
          (1 (- a2 a1))
        )
      )
    )
    ;; Function to convert a 3D point into 2D for the purpose
    ;; of ignoring the Z value.
    ;; Added (09-20-03)
    (defun @2D (p)(list (car p)(cadr p)))
    ;;-----------------------------------------------------
    ;; Function to determine if an angle is with the sector
    ;; defined by two other angles.
    ;; Returns the delta angle from the first angle.
    ;;
    (defun @insect (Ang Ba Ea)
      (if (> Ba Ea)
        (cond
          ((>= Ang Ba))
          ((<= Ang Ea))
          (1 nil)
        )
        (< Ba Ang Ea)
      )
    )
    (defun @Bulge (Param / Bulge V1 V2 Half Delta Chord Radius Center Ba Ea Ang P)
      (and
        (setq Bulge (vl-catch-all-apply 'vla-getbulge (list Object (fix Param))))
        (numberp Bulge)
        (/= Bulge 0)
        (< Param End)
        (setq V1 (vlax-curve-getpointatparam Object (fix Param)))
        (setq V2 (vlax-curve-getpointatparam Object (1+ (fix Param))))
        (setq V1 (trans V1 0 1))
        (setq V2 (trans V2 0 1))
        (setq Half   (if (minusp Bulge) -0.5 0.5)
              Delta  (* 4.0 (atan (abs Bulge)))
              Chord  (distance V1 V2)
              Radius (/ Chord 2 (sin (/ Delta 2)))
              Center (polar V1 (+ (angle V1 V2)(* (- pi Delta) Half)) Radius)
        )
        (if (minusp Bulge)
           (setq Ba (angle Center V2) Ea (angle Center V1))
           (setq Ba (angle Center V1) Ea (angle Center V2))
        )
        (setq Ang (angle Center PIQ))
        (@insect Ang Ba Ea)
        (setq P (polar Center Ang Radius))
      )
      P
    )
    (and
      (cond
        ((not Object)
          (prompt "  No object provided.")
        )
        ((= (type Object) 'VLA-Object))
        ((= (type Object) 'Ename)
          (setq Object (vlax-ename->vla-object Object))
        )
        (1 (prompt "  Improper object type."))
      )
      (or
        (and
          (< 1 (vl-list-length PIQ) 4)
          (vl-every 'numberp PIQ)
        )
        (prompt " Improper point value.")
      )
      (or
        (not
          (vl-catch-all-error-p
            (setq Start
              (vl-catch-all-apply
                'vlax-curve-getStartPoint
                (list Object)
              )
            )
          )
        )
        (prompt "  Object is not a curve.")
      )
      (or
        (equal Start (vlax-curve-getendpoint Object) 1e-10)
        (prompt "  Curve is not closed.")
      )
      (setq P (trans PIQ 1 0)) ; PIQ in WCS
      (setq Closest
        (vlax-curve-getclosestpointto Object P) ; In WCS
      )
      ;; Test to see if PIQ is on object:
      (not (equal (@2D P)(@2D Closest) 1e-10)) ; in WCS
      (setq End (vlax-curve-getEndparam Object))
      (if (= (vla-get-objectname Object) "AcDbSpline")
        (setq Sample (/ End 100))
        (setq Sample 1.0)
      )
      (setq Param Sample Defl 0.0)
      (setq a1 (angle PIQ (trans Start 0 1))) ; in UCS
      (while (<= Param End)
        (setq Param (min Param End))
        (setq P    (vlax-curve-getpointatparam Object Param)
              a2   (angle PIQ (trans P 0 1)) ; in UCS
              Defl (+ Defl (@delta a1 a2))
              a1 a2
        )
       ; (grdraw PIQ P 3)
        (if (setq P (@Bulge Param))
          (progn
            ;(grdraw PIQ (trans (vlax-curve-getpointatparam Object P1) 0 1) 1)
            ;(grdraw PIQ P 1)
            ;(grdraw PIQ (trans (vlax-curve-getpointatparam Object P2) 0 1) 3)
            (setq a2 (angle PIQ P)
                  Defl (+ Defl (@delta a1 a2))
                  a1 a2
            )
          )
        )
        (setq Param (+ Param Sample))
      )
      ;(print Defl) ; Optional display of results
      (> (abs Defl) 4)
    )
  )

John F. Uhden

0 Likes
Message 11 of 15

marko_ribar
Advisor
Advisor

@john.uhden

 

The function is_inside is not Lee's function but my mr_IsPointInside with changed name to reflect OP's rest of defined functions... I don't know why do you don't get T or nil as return - that's what it should do, I only implemented substitution for which I think is correct according to OP's is_inside function - neither OP is dealing with bulges... But then again, you are right - OP's function should take into consideration general case and that's PLINES with bulges or not... Either way I think that OP's function is_inside is somewhat worse than mine as like I've explained it works only with visible portion of current ACAD interface... Please, if you recheck my version, you'll see that it should return T for point that's inside POLYGON and nil if it's on or outside of it...

Marko Ribar, d.i.a. (graduated engineer of architecture)
0 Likes
Message 12 of 15

john.uhden
Mentor
Mentor

@marko_ribar

 

I apologize for misinterpreting the correct author.  Most all contributions here are highly valued.  I was merely looking for ways to speed up the apparently slow code.  Hopefully the OP is gaining some knowledge from our responses.

 

BTW, the vl-remove-if-not method IS probably the fastest way to create a point list from a LWPolyline.  I tried to time it but my laptop crapped out in the middle of my testing, as usual.

John F. Uhden

0 Likes
Message 13 of 15

julie.pomeroyP5QW5
Explorer
Explorer

As I do appreciate everyone diagnosing the lisp code, it still makes me wonder why it runs perfectly fine in 2014 & 2015 and like molasses in 2016! 

Can anybody please explain?  Or, could it be a hardware issue?

0 Likes
Message 14 of 15

stevor
Collaborator
Collaborator

1. The 'append  functions make a nil value;

change or use  another subr, like others provided.

 

2. Check your PC for reactors,

a big unknown in actual  operation.

S
0 Likes
Message 15 of 15

Kent1Cooper
Consultant
Consultant

@john.uhden wrote:

.... There are probably even faster functions out there, like anything that @Kent1Cooper would build using (vl-remove-if-not). ....


In case it's of any use to you, this is how I would get a list of vertices in that way from a LWPOLYLINE whose entity name is supplied as the 'ename' argument:

(defun plverts (ename)

  (mapcar 'cdr ; strip the 10's off, leaving the coordinate lists

    (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget ename))

  ); mapcar

); defun

 

It's pretty concise as to length of code, but I leave it to others to test whether it's faster than other approaches.  It won't work on "heavy" [whether 2D or 3D] Polylines.

Kent Cooper, AIA
0 Likes