Exploding blocks with autolisp

I have been trying to write a lisp routine that will explode all the blocks (including nested blocks) in a drawing, ignoring any xrefs. I am fairly new to lisp, and I have run out of ideas to try. If anyone can help me with this I would greatly appreciate it.

TJ

Reply to
tkennedy
Loading thread data ...

Show us what you have so far.

Reply to
Michael Bulatovich

You say you are fairly new... It would be much better to learn about blocks and how use them rather than explode them. Blocks are much much much more useful and speed enabling than the entities they are made of.

I've been at it for 23 years (Intergraph in 1983, then AutoCAD in 1989) and the top two mistakes new users make are xref bind, and explode. There are excellent ways to get them to do what you need without ever doing either.

Reply to
Henry C. Francis

Perhaps a little more backround information would help. I work for an engineering firm, and we receive background drawings from the architect that we xref into our drawings. It has become increasingly dificult to use their drawings without editing the somewhat, so we are trying to create a lisp routine to do the editing for us. What we need to do is get set everthing to bylayer for color, remove all unnecessary xrefs, and set all layers to a specific color. As for exploding the blocks, it is dificult for us to freeze the layers we dont need in our drawings if there are blocks in the arch. backgrounds. For example, if the architect has a standard room block, we cant use our express tools to freeze the furniture, it will freeze the entire block (usualy on layer

0). Granted, we will run into the same problem if everything in the block is on the same layer, but that is rare.

As for what I have so far, I have this:

(defun c:test () (setq ss (ssget "x" '((0 . "insert"))) c 0) (repeat (sslength ss) (command ".explode" (ssname ss c)) (setq c (1+ c))) )

I d> You say you are fairly new... It would be much better to learn about blocks

Reply to
Maintenancedude2000

That should explode every block in the drawing, unless they've on locked and/or frozen layers.

Some of the express tools used to have Options prompt which can affect what gets turned off. Do you get an Options prompt with whatever you're using?

Reply to
Michael Bulatovich

Reply to
Maintenancedude2000

Reply to
Henry C. Francis

Reply to
Maintenancedude2000

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.