Lisp to explode, close corners, overkill, purge, and flatten all geometry.

Lisp to explode, close corners, overkill, purge, and flatten all geometry.

Anonymous
Not applicable
3,326 Views
5 Replies
Message 1 of 6

Lisp to explode, close corners, overkill, purge, and flatten all geometry.

Anonymous
Not applicable

I am new to the lisp world and trying to learn a new aspect of AutoCAD. 

In hopes to try and get the design department more efficient and quicker I am wanting to figure out how to write a lisp that we can load one time into our computers. Every time we are preparing a DXF we have to do a series of things which includes:

Explode everything a few times just to make sure everything is lines not polylines

Check all the corners of our parts and close them

Overkill everything 

Purge all and cycle through and continue to purge all items 

The last step is to flatten everything so it is all on elevation 0' 0"

there has been many drawing that gone out incomplete and if I could figure a way to combine all this to do it automatically that would be tremendous!

 

Any ideas on how to write this lisp so that it is fully automatic? 

 

Thanks in advance for any and all help getting me closer to my goal,

 

Seth Brathovd

 

0 Likes
3,327 Views
5 Replies
Replies (5)
Message 2 of 6

john.vellek
Alumni
Alumni

HI @Anonymous,

 

While you wait here for suggestions from other members, I thought I would mention that you might be able to use the Action Macro Recorder to do these steps.

 

Once you save your Macro(s) they can even be called from a LISP routine.

 

 

Please select the Accept as Solution button if my post solves your issue or answers your question.


John Vellek


Join the Autodesk Customer Council - Interact with developers, provide feedback on current and future software releases, and beta test the latest software!

Autodesk Knowledge Network | Autodesk Account | Product Feedback
0 Likes
Message 3 of 6

3wood
Advisor
Advisor

You can collect some routines in the forum and combine them together as one lisp routine.

Then you can run it in all subfolders and files automatically.

Here is an example:

(defun c:Prepare ()
  ;STEP 1: Explode all blocks
  (EXPLODEALL (ssget "x"))

  ;STEP 2: Explode all polylines
  (command "EXPLODE" (ssget "x" '((0 . "LWPOLYLINE"))))

  ;STEP 3: Check all the corners of our parts and close them
  ;Need more information to work out the function

  ;STEP 4: Overkill everything
  (command "-OVERKILL" "All" "" "Done")

  ;STEP 5: Purge all and cycle through and continue to purge all items
  (command "-PURGE" "All" "*" "N")

  ;STEP 6: flatten everything so it is all on elevation 0' 0"
  (Chz20_cmd T)
  )

Not sure about STEP 3, but I think it wouldn't be hard if you would like to square off all the outmost corners of the parts.

This lisp uses EXPLODEALL and CHZ20 . You need download them first, set up their settings, and add them to your "Startup Suite" with command APPLOAD so that they can be loaded automatically into all drawings.

 

Message 4 of 6

john.vellek
Alumni
Alumni

Hi @Anonymous,

 

I am coming back to your thread to see if the issue or question you posed has been resolved.  If so, please mark the post or posts as Solution(s) to help others find the answer quickly. If your issue persists, please give me a bit more detail on this issue so we can continue to work towards getting this solved.


John Vellek


Join the Autodesk Customer Council - Interact with developers, provide feedback on current and future software releases, and beta test the latest software!

Autodesk Knowledge Network | Autodesk Account | Product Feedback
0 Likes
Message 5 of 6

Anonymous
Not applicable

Okay, so after sitting on here some more yesterday I have what i think might work I have used an action record for step 1 which i dont really like and lisp to combine a couple steps which will work but I definitely know it could be better.  

 

 

As for the step on checking corners I did some testing and if the lisp were to work something like this: 

(defun C:STEP1()

(Command "layfrz") ; User selects layers to freeze

(command "-layer" "new" "Open Lines" "set" "Open Lines" "") ;Creates new layer and set it as current 

(command "qselect"...... this i do dont know how to alter to make things like (apply to entire drawing, change object type to polyline, change properties to closed, and change value to no.) apply in that window. 

After that... (whatever is left selected needs to be switched over to the newly created layer) need some help on that.... once all of that is complete they can manually close their lines and then run step 2 

So for step 2 this is what i have 

(defun c:step2 ()
(command "explode" "all" "") ;Explode not working 
(command "explode" "all" "") ;Explode not working 
(command "explode" "all" "") ;Explode not working making sure all nested blocks are exploded
(command "_change""_all""""p""e""0""") ;moves all objects to elevation 0' 0"
(command "-overkill" "all" "" "done")
(command "-purge" "all" "" "no")
(alert "Don't forget to check over your work once more.")
)

Only issue with this, it worked yesterday but this morning it does not want to work.( any idea what i am doing wrong?)

I also looked into the EXPLODEALL AND CHZ20 I dont know if I want to use those with the registration and all. I found (command "_change""_all""""p""e""0""") which sets everything at 0 on Z, this works great. 

 

 

0 Likes
Message 6 of 6

3wood
Advisor
Advisor

To select all polylines and close them, you can use (ssget) instead of Command Qselect. You can also add layer filter in ssget.

(command "PEDIT" "Multiple" (ssget "x" '((0 . "LWPOLYLINE"))) "" "Close" "Ltype" "On" "")

0 Likes