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.
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.
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")))
(repeat (sslength ss)
(command ".explode" (ssname ss c))
(setq c (1+ c)))
I dont have any of the layer or xref commands in yet, but those I know
how to do and will add them later when I get this part working.
Henry C. Francis wrote:
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?
I am using layfrz, which does have some options, but that is not usualy
a problem. Something I forgot to mention is that we need everything to
be by layer for color, so we can set it to the color we want in our
drawings. We do this to make everything plot with a light lineweight.
If a line in a block is set to any color but by layer, we cant change
it in our drawing. If I explode all the blocks, I can then use change
to make everything by layer. The routine I have will explode the bound
xref I have in the drawing, then stop. When I run it again, it
explodeds most of the blocks, than prints
to the command line.
Michael Bulatovich wrote: