p7q Posted 3 hours ago Posted 3 hours ago Hi everyone, I'm working with a large AutoLISP routine that sets the Z elevation of all objects to 0 — similar to a custom Z0 command. It handles a wide range of entity types including: LINEs, ARCs, CIRCLEs, POLYLINEs (both 2D and 3D), LWPOLYLINEs, SPLINEs, HATCHes, TEXT, MTEXT, DIMENSIONs, INSERTs (blocks), including nested block content, and REGION entities. What it does: For each entity, I check its Z elevation and flatten it: For regular entities, I modify their coordinate group codes (10, 11, etc.) using entmod, or use vla-put-elevation where applicable. For INSERTs, I dive into their nested entities and apply the same logic. For REGIONs, I currently copy and explode them temporarily, analyze the resulting geometry to determine the average Z, then move the original REGION to Z=0. My problem: The command works fine, but performance is a major issue, especially on complex or large drawings. What are the best ways to optimize performance for a routine like this? Is there a better way to flatten REGIONs without exploding them? Specifically, is there a way (maybe via a filter or a helper LISP) to select only entities whose Z coordinate is not zero? That would allow me to skip processing objects that are already flat and significantly improve performance. Thanks a lot in advance for any suggestions! Quote
Steven P Posted 2 hours ago Posted 2 hours ago Here is a quick example, (ssget (list '(-4 . "<OR") '(-4 . "*,*,<>") (list 10 0.0 0.0 0.0) '(-4 . "*,*,<>") (list 11 0.0 0.0 0.0) '(-4 . "OR>") )) Should select the more simple entities not at 0 elevation - not sure it will work for 3d polylines for example, but should be OK for lines, circles, arcs and so on and apply similar to others? Quote
Steven P Posted 2 hours ago Posted 2 hours ago I guess the flatten command has some limitations for you (I've never been 100% with trusting flatten) Quote
p7q Posted 1 hour ago Author Posted 1 hour ago 5 minutes ago, Steven P said: I guess the flatten command has some limitations for you (I've never been 100% with trusting flatten) yes flatten is not working sometimes block, pline, dimension. So ı need this lisp. 8 minutes ago, Steven P said: Here is a quick example, (ssget (list '(-4 . "<OR") '(-4 . "*,*,<>") (list 10 0.0 0.0 0.0) '(-4 . "*,*,<>") (list 11 0.0 0.0 0.0) '(-4 . "OR>") )) Should select the more simple entities not at 0 elevation - not sure it will work for 3d polylines for example, but should be OK for lines, circles, arcs and so on and apply similar to others? this lips so limited. for exaple there are multiple 10 dxf data in POLYLINE. I need something more comprehensive Quote
mhupp Posted 55 minutes ago Posted 55 minutes ago Can't really tell you how to optimize code you didn't post, but when people first get into lisp the rely heavily on command because its follows what you would type into the command line. It become apparent in a loop processing 1000's of entity's that its quite inefficient. rather then using entmod or some other way to update model. If flatten doesn' work also try the command Change > elevation > 0 1 Quote
Steven P Posted 14 minutes ago Posted 14 minutes ago 1 hour ago, p7q said: this lips so limited. for exaple there are multiple 10 dxf data in POLYLINE. I need something more comprehensive That would get most of the simpler entities such as lines, text, circles and so on. LWPolylines you can add another "or": '(-4 . "<>") (cons 38 0.0) and so on building up the selection set filter that way: (ssget (list '(-4 . "<OR") '(-4 . "*,*,<>") (list 10 0.0 0.0 0.0) '(-4 . "*,*,<>") (list 11 0.0 0.0 0.0) '(-4 . "<>") (cons 38 0) '(-4 . "OR>") )) For 3d polylines, for example, so long as the first point (first dxf code 10 in the entity description) isn't at zero elevation it should also grab them too. However if this only removes lines, LWPolylines, circles, arcs, texts, ellipses... it should reduce the amount of processing. Depends how you are doing it but the blocks might be your slow point. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.