Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Lisp to select all blocks & explode them question

7 REPLIES 7
Reply
Message 1 of 8
CADDapult
11708 Views, 7 Replies

Lisp to select all blocks & explode them question

I've got to be overthinking this (or underthinking it):

 

I use  (setq AllBlocks (ssget "X" (list (cons 0 "INSERT"))))  to select all the blocks in a drawing.

 

If I manually run the Explode command and enter !AllBocks at the command line for the selection all the blocks are exploded in one fell swoop  If, in a lisp routine I  use  (command "explode" AllBlocks "") or (command "explode" "!AllBlocks" "") i don't get the same result.  I can use a loop to explode one block at a time until they're done, but that takes quite a bit longer.  What am I missing?

 

The purpose of this is to help convert our 3D assemblies, made up of blocks containing solid entities, into a model with only solids so the ACISOUT command can be used.

 

Any help would be appreciated,

Mike

More of a curmudgeon by the hour
7 REPLIES 7
Message 2 of 8
lpseifert
in reply to: CADDapult

Try setting Qaflags=1 first and see if that works

(setvar "qaflags" 1)

~~~Civil 3D 2008~~~
Message 3 of 8
CADDapult
in reply to: lpseifert

Nope, no change.  Still doesn't allow me to explode the selection set of blocks in one operation.

 

Mike

More of a curmudgeon by the hour
Message 4 of 8
Kent1Cooper
in reply to: CADDapult

Try searching the Discussion Group history for QAFLAGS.  There have been many threads on this issue, and that has always been at least part of the solution, but you might find one that says more.

Kent Cooper, AIA
Message 5 of 8
CADDapult
in reply to: Kent1Cooper

Fat Finger Syndrome (a typo) had me thinking it didn't work, when in fact it *does* work.  Sorry about that guys.  I need to slow down, or better yet get my boss to lay off the whip 😛

Thanks very much for the help, it is greatly appreciated.

Mike 

 

edit:

Here is the basic routine to explode blocks, including nested, while preserving Solids for export to an ACIS file:

 

(defun C:ACISPrep (/ AllBlocks SolOnly )
(setvar "qaflags" 1)
(setq AllBlocks (ssget "X" (list (cons 0 "INSERT"))))
 (while (/= AllBlocks nil)
  (progn
   (command "_.explode"  AllBlocks "")
   (setq AllBlocks (ssget "X" (list (cons 0 "INSERT"))))
  );progn
 );while
(if (= AllBlocks nil)(alert "All blocks were exploded"))
(setq SolOnly (ssget "X" '((0 . "3DSOLID"))))
(command  "_.erase" "all" "R" SolOnly "")
(alert "All non-Solid entities deleted. Purge file before exporting to ACIS.")
(setvar "qaflags" 0)
(princ)
);end ACISPrep

 

Thanks again!

 

More of a curmudgeon by the hour
Message 6 of 8
3wood
in reply to: CADDapult

You can also try attached EXPLODEALL.vlx.

Message 7 of 8
Zulander1
in reply to: CADDapult

 Hello CADDapult,

 

 

I am using your function ACISPrep, which work's great, the only problem i have is that it keeps freezing when i am using a script file (for batch processing )!!!

calling this script like this:

(ACISPrep )

 

 

this is the output of script :

 

Command: _.explode
Select objects: 264 found

Select objects:
Command: _.erase
Select objects: all 2504 found

Select objects: R
Remove objects:  <---get stuck's her!!

 

 

 

i've modifed it to remove all the alerts:

 

(defun ACISPrep (/ AllBlocks SolOnly )
(setvar "qaflags" 1)
(setq AllBlocks (ssget "X" (list (cons 0 "INSERT"))))
 (while (/= AllBlocks nil)
  (progn
   (command "_.explode"  AllBlocks "")
   (setq AllBlocks (ssget "X" (list (cons 0 "INSERT"))))
  );progn
 );while
(setq SolOnly (ssget "X" '((0 . "3DSOLID"))))
(command  "_.erase" "all" "R" SolOnly "")
(setvar "qaflags" 0)
(princ)
);end ACISPrep

Thank you 

Message 8 of 8
jrreid
in reply to: CADDapult

Wow!! This is the word I used to describe the action of your lisp file. All blocker were exploded.

I had the numbers but this website timed out before I got back to adding them.

This is a very large conveyor drawing and it worked great.

 

Then I used:  

(command "_move""_all""""""0,0,1e99""_move""_all""""""0,0,-1e99")

 to get them to true 0,0,0 care of https://knowledge.autodesk.com/support/autocad/learn-explore/caas/sfdcarticles/sfdcarticles/how-to-f...

 

Then I used OVERKILL to take out the unwanted lines and circles due to multi stories being taken down to 1.

 

Thanks!! JRR.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost