;NextVertex - a Lisp trick to access successive vertices of entity (assoc 10 EDDY) ;Inspired by "AutoLisp Question re: Leaders" of chrisj5 of this Forum
;www.homescript.com ;------------------ (defun C:NextVertex() ;Select Objects - for debugging/tutorial - later you drop this ;and call NextVertex1(yourEntity) ;from within your function, with yourEntities from your SelectionSet as argument ;In Lisp tutorials I use this naming convention: ;Suzy for selection set ;Suzilen for number of elements picked ;Sneaky for counter ;EDNA for entity name ;EDDY for full list of entity data ;ShortEDDY for truncated entity list - came into being today, solely for this example. (setq Suzy (ssget)) (setq Suzilen (sslength Suzy)) (setq Sneaky 0) (while (< Sneaky Suzilen) (setq EDNA (ssname Suzy Sneaky)) (setq EDDY (entget EDNA)) (print Sneaky)(Princ "\nEDDY ... ") (print EDDY) (setq Sneaky (+ 1 Sneaky)) (NextVertex1 EDDY) ) ) ;----------------- (defun dxf (n ed) (cdr (assoc n ed))) ;------------------- (defun NextVertex1(ShortEDDY) (princ "\nSuccessive access to (Assoc 10 EDDY) ... ") (while (setq ShortEDDY (member (assoc 10 ShortEDDY) ShortEDDY)) ;for debugging (princ "\n(assoc 10 ShortEddy)..") (princ (assoc 10 ShortEDDY)) ;after debugging, put other function calls here ;to do things with vertex coordinates ;or assign the coordinates to a parameter, to use elsewhere (setq nextVertexCoords (cdr (assoc 10 ShortEDDY))) (setq ShortEddy (cdr ShortEddy)) ) (princ) ) ;---------------------
This was for polylines which have all the vertices in one entity list - no SEQUEND there. Multiple (10 xx) appear in the entity list and the lisp above extracts them.
For other entities with SEQUEND, it is all together a different issue, the solution for which, given by Striker is:
You could also show how to access each individual vertice on a complex entity pline, such as a regular polyline or 3dpoly. I personally would do it like this.... ELIST is the entity list of a complex POLYLINE entity
Since the later 1980s, manufacturing companies have seen over 3 percent in labor output year on year, with most of this productivty enhancement occuring because of the optimization of repetitive tasks. Download Now