There is a quicker way of retrieving the entity list of a Polyline vertex. (setq e (entget (entnext (cdr (car e))))) while loop control is not nil, carry on looping Here's an example of a function that will print the coordinates for each vertex of a Polyline : (defun c:coord ( / e r) We just need to loop through the sequence of vertices until we reach the SEQEND list. To extract the entitity list for each vertex is therefore, quite easy. Take note of the entity type of each variable :ĭo you see that a 3 line Polyline consists of a master or, parent list, 4 vertex and an end-of sequence ( "SEQEND") list.
Each code segment then uses the (entnext entity name) of the entity that precedes it. The (cdr (car e)) returns the entity name of entity list e. "AcDbEntity")Ĭommand: (setq e5 (entget (entnext (cdr (car e4))))) 32)Ĭommand: (setq e4 (entget (entnext (cdr (car e3))))) 32)Ĭommand: (setq e3 (entget (entnext (cdr (car e2))))) 0))Ĭommand: (setq e2 (entget (entnext (cdr (car e1))))) Now type the following 5 code segments : Command: (setq e1 (entget (entnext (cdr (car e))))) This is where the (entnext) function comes into play. Hey, wait a minute!… AutoLisp has returned the entity list, and I can see that it's a Polyline, but there are no co-ordinates, and where does AutoLisp get the co-ordinates for all the vertices?Īs I said earlier, we need to dig a little bit deeper to get the information we require. Then type this : Command: (setq e (entget (car (entsel))))ĪutoLisp should return something like this : Select object: ((-1. We will have a look at the R13 and below Polyline first. When a drawing from a previous release is opened in Release 14 and above, all 2D polylines convert to lwpolylines automatically unless they have been curved or fitted or contain xdata. 2D polylines are created as lwpolyline entities by default unless they have been curved or fitted with the PEDIT command. In Release 14 and above, 3D polylines are always created as standard polyline entities. Lwpolylines display faster and consume less disk space and RAM. This is different than a standard polyline, which is defined as a group of subentities. A lwpolyline is defined in the drawing database as a single graphic entity. The LwPolyline (Light Weight Polyline) entity, or "optimized polyline," was introduced with Release 14. So bear with me, take your time, and hang on for a ride on the magic carpet… Polylines In fact, once we get there I'll show you a couple of things that you swear is magic. I know that they are called "complex entities", but the only difference between them and other entities is that we just have to dig a bit deeper to get to what we want. Honestly, they are a lot easier to deal with than you think. Polylines and Blocks! Come back… Don't run away…