Jump to content

Performance helps for Large-Scale Z-Flattening (Z0) AutoLISP Routine?


Recommended Posts

Posted

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!

Posted

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?

Posted

I guess the flatten command has some limitations for you (I've never been 100% with trusting flatten)

Posted
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

Posted

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

  • Like 1

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...