![]() ![]() Want to create your own entity? Normally, in AutoLISP you would draw a line like this: I told you it was easy! Remember, I've only scratched the surface with the things that you can do once you dig into entity lists, especially with complex entities. Well, that's it concerning Polylines and Blocks. repeat for the length of the entity list Once found, we can easily extract the vertex co-ordinates. Then we must loop through each code entity in the list searching for a group 10. (As well as Group 40 - Start Width Group 41 - End Width and Group 42 - Bulge) To extract these, we need to first, find the length of the list. But, we do have another problem!! There are numerous group 10 entity codes. 0.0) (210 0.0 0.0 1.0))Īs you can see, there is no need to use (entnext) to step through the vertex entities as the group 10 entity code is already part of the parent list. Draw a LwPolyline and enter this: (setq e (entget (car (entsel))))ĪutoLisp should return something like this: Let's have a look at a LwPolylines entity list. They differ in that they are defined as a single entity. Well you can now… LwPolylinesĪs we mentioned earlier, LwPolylines were introduced with AutoCAD Release 14. I bet you never thought you would be able to modify a block without exploding it. I told you it was magic…Īgain, REGEN the drawing. In other words, every block in the drawing with the same name would have changed. Not only that, it has also redefined the block definition. Did you noticed what happened? The radius of the circle has change even though it's part of a block. It's returned the entity list of the circle even though it's part of a block! Now type the following: AutoLisp should return something like this: Select object: ((-1. Now type this : (setq e (entget (car (nentsel)))) Now, while we're here, let's have a quick look at blocks… BlocksĬreate a block consisting of a couple of lines and a circle with a radius of 20. (setq e (entget (car (nentsel))))ĪutoLisp should return something like this : Type this, then select any vertex of a polyline. The function (nentsel) let's you select an entity and returns the name of the entity even if it belongs to a polyline. 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…
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |