LISP explode doesn't work

572 views
Skip to first unread message

CLS

unread,
Jul 21, 2004, 11:23:14 AM7/21/04
to
Hi All,

I need to explode everything in my drawing. The problem is that our blocks
are not that great. We have blocks inside blocks.

When my LISP routine executes the explode it explodes all the selected
items. But there are still some blocks that exist. So I doubled the
explode command, but it doesn't find the new blocks. If I type in explode
then all, it still doesn't work. I have to use the mouse and select all the
items by a window and then type explode.

How can I do this in my LISP routine?

Chad

--

________________________________
Cameron Land Surveying Ltd.
#203-6333 148 Street
Surrey, BC V3S 1C1

(o) (604) 597-3777
(f) (603) 597-3783

All E-Mail Scanned with Norton Anti-Virus


ECCAD

unread,
Jul 21, 2004, 11:52:18 AM7/21/04
to
(repeat 5 ; 3 or more..
(setq ss (ssget "ALL"))
(command "_explode" ss "")
); end repeat

Alan Henderson @ A'cad Solutions

unread,
Jul 21, 2004, 12:04:11 PM7/21/04
to
Or

(while (setq SS (ssget "ALL"))
(command "_explode" SS "")
)

"ECCAD" <nos...@address.withheld> wrote in message
news:11463480.1090425171360.JavaMail.javamailuser@localhost...

Jason Piercey

unread,
Jul 21, 2004, 12:13:47 PM7/21/04
to
That creates a infinite loop. You'd be better off
specifying the types of entities that can be exploded
or using the QAFLAGS variable as a work around.

--
Autodesk Discussion Group Facilitator


"Alan Henderson @ A'cad Solutions" <REMOV...@acadsolutions.biz> wrote in
message news:40fe9431$1_3@newsprd01...

Jürg Menzi

unread,
Jul 21, 2004, 12:16:13 PM7/21/04
to

Cool, endless loop...8-)

Cheers
--
Juerg Menzi
MENZI ENGINEERING GmbH, Switzerland
http://www.menziengineering.ch

Doug Broad

unread,
Jul 21, 2004, 12:24:36 PM7/21/04
to
Do you want to explode only blocks or also
polylines and mtext? If you only want to explode
only block references, then something like this might
be better. The filter list could be expanded.

;;Explode all inserts
(defun c:xpall () ;;D. C. Broad 2004
(setvar "qaflags" 1)
(while (setq ss (ssget "x" (list (cons 0 "insert"))))
(command "explode" ss ""))
(setvar "qaflags" 0)
(princ)
)

"CLS" <camer...@NOTshaw.ca remove NOT> wrote in message news:40fe8a68$1_3@newsprd01...

ECCAD

unread,
Jul 21, 2004, 12:28:42 PM7/21/04
to
Why not,

(while (setq SS (ssget "ALL"))
(command "_explode" SS "")
(command "_regen")
)

Makes the loop even longer...
:)
Bob

CLS

unread,
Jul 21, 2004, 1:07:05 PM7/21/04
to
Thanks
I tried your idea, but it still doesn't work. It says the object is not
able to be exploded. It is a simple block. If I click on it and type
explode, it works, but everything I try is Lisp doesn't

Chad


"ECCAD" <nos...@address.withheld> wrote in message
news:11463480.1090425171360.JavaMail.javamailuser@localhost...

CLS

unread,
Jul 21, 2004, 1:16:38 PM7/21/04
to
Hang on,

I tried it again, and it worked. So I tried it a couple of times, and it
randomly works.

???
Chad


"CLS" <camer...@NOTshaw.ca remove NOT> wrote in message

news:40fea2bf$1_2@newsprd01...

ECCAD

unread,
Jul 21, 2004, 1:38:25 PM7/21/04
to
You said 'everything' .. see Doug's program - will work just fine.

Bob

ECCAD

unread,
Jul 21, 2004, 1:45:49 PM7/21/04
to
It will error when it finds an item that cannot be exploded..and just exits the loop. Would appear to be random. I like Doug's approach..try that..

Bob

Doug Broad

unread,
Jul 21, 2004, 1:51:02 PM7/21/04
to
Sigh... Sometimes posting seems to be a waste of time
when the person being helped doesn't even notice.
Thanks Bob.


"ECCAD" <nos...@address.withheld> wrote in message news:24014580.109043153...@jiveforum1.autodesk.com...

ECCAD

unread,
Jul 21, 2004, 2:22:55 PM7/21/04
to
Doug,
Yes, I know what you mean. (:
Bob

CLS

unread,
Jul 21, 2004, 2:34:49 PM7/21/04
to
OK Doug,

I tried your. It appears to do nothing. This is what is displayed on the
prompt:
C:XPALL

all blocks are still blocks.

Now what?
Chad

PS: I did try yours. How do I expand the filter list to include everything?


"Doug Broad" <nospam@address-withheld> wrote in message
news:40fe98c9$1_1@newsprd01...

Doug Barr

unread,
Jul 21, 2004, 2:41:28 PM7/21/04
to
Layers locked?

"CLS" <camer...@NOTshaw.ca remove NOT> wrote in message

news:40feb74f$1_3@newsprd01...

Doug Broad

unread,
Jul 21, 2004, 2:43:51 PM7/21/04
to
Chad,
You just loaded it. It creates a command called XPALL.
Enter the command at the keyboard.


"CLS" <camer...@NOTshaw.ca remove NOT> wrote in message news:40feb74f$1_3@newsprd01...

CLS

unread,
Jul 21, 2004, 2:45:07 PM7/21/04
to
Here is the complete scenario. We use a different program for our drafting.
We have to submit the drawings to the city. They have an exact set of
rules. When we export the file to dxf, linetypes, colours, & blocks are
messed up.

I have done the layer assignments already & the colours, except, that the
blocks have lines from other layers, so I have to explode the block so I can
change the layers of the lines inside the block. Not everything on the
drawing is blocks, I have text, mtext, plines, lines, etc.

If I highlight everything and type explode, it will say 10 items found 5
items could not be exploded. So I do it again, then it might say 20 items
found, 15 could not be exploded. So I do it again, and it might say 100
items found 100 items could not be exploded.

Now I know all items are exploded, and I can select everything and change it
so that the colour, linetype are 'bylayer'.

I want to be able to do this with a lisp command.

Chad

ECCAD: your way works occasionally. From what I understand, if it comes
across a line it stops the lisp routine because it cannot be exploded.

Doug: your did nothing.


"CLS" <camer...@NOTshaw.ca remove NOT> wrote in message

news:40feb74f$1_3@newsprd01...

CLS

unread,
Jul 21, 2004, 2:45:58 PM7/21/04
to
That was quick, let me try again. XPALL

"CLS" <camer...@NOTshaw.ca remove NOT> wrote in message
news:40feb9ba_3@newsprd01...

Tom Smith

unread,
Jul 21, 2004, 2:46:39 PM7/21/04
to
He might need to try hitting ALT+F4 a few times...


CLS

unread,
Jul 21, 2004, 2:48:39 PM7/21/04
to
Doug,

That works perfectly.

Thanks everyone.

Chad


"CLS" <camer...@NOTshaw.ca remove NOT> wrote in message
news:40fe8a68$1_3@newsprd01...

Doug Broad

unread,
Jul 21, 2004, 2:49:31 PM7/21/04
to
What exactly do you want to explode? I
can't see a reason to explode mtext or polylines,
can you?

Before using the command you should make sure
all layers are unlocked as Doug Barr explained.

If you want to include everything, you need to
delete the (list (cons 0 . "insert")) but then
it will error out because it tries to explode
unexplodable objects. To include mtext and
polyline, modify:

(list (cons 0 . "insert,mtext,LWPOLYLINE"))

If you explode polylines, you lose the width and
curve fit parameters.


"CLS" <camer...@NOTshaw.ca remove NOT> wrote in message news:40feb74f$1_3@newsprd01...
> OK Doug,

Doug Broad

unread,
Jul 21, 2004, 2:52:34 PM7/21/04
to
<snicker>

"Tom Smith" <nospam> wrote in message news:40feba0f$1_2@newsprd01...

CLS

unread,
Jul 21, 2004, 3:05:44 PM7/21/04
to
Thanks Tom,

May your next blue screen be permanent.

Chad

"Tom Smith" <nospam> wrote in message news:40feba0f$1_2@newsprd01...

ECCAD

unread,
Jul 21, 2004, 3:10:17 PM7/21/04
to
Long trail, but a happy camper.

Bob

Joe Burke

unread,
Jul 25, 2004, 7:53:38 AM7/25/04
to
Hi Doug,

Check me. I think there's a problem with xpall when the drawing contains xrefs. It
goes into an endless loop because the xrefs can't be exploded. But of course they
continue to be added to ss within the while loop based on the "insert" filter.

> ;;Explode all inserts
> (defun c:xpall () ;;D. C. Broad 2004
> (setvar "qaflags" 1)
> (while (setq ss (ssget "x" (list (cons 0 "insert"))))
> (command "explode" ss ""))
> (setvar "qaflags" 0)
> (princ)
> )

Here's something which I think avoids that problem. It probably could be tighter, and
it might not be perfect, but you get the idea. Comments welcome.

(defun c:ExplodeAllInserts ( / doc mspace )
(setq doc (vla-get-ActiveDocument (vlax-get-acad-object)))
(setq mspace (vla-get-ModelSpace doc))
;return T while there are inserts which are not xrefs
(while
(vlax-for x mspace
(if
(and
(= "AcDbBlockReference" (vlax-get x 'ObjectName))
(not (vlax-property-available-p x 'Path))
)
T
)
)
(vlax-for x mspace
(if
(and
(= "AcDbBlockReference" (vlax-get x 'ObjectName))
(not (vlax-property-available-p x 'Path))
)
(progn
(vlax-invoke x 'Explode)
(vlax-invoke x 'Delete)
)
)
)
) ;while
(princ)
) ;end

Regards
Joe Burke


Doug Broad

unread,
Jul 25, 2004, 12:16:51 PM7/25/04
to
Great points Joe. I overlooked xrefs. Oops.
Looked at your program and made a few changes. What
do you think?

;;A program by Joe Burke with changes by D.C. Broad
;;Explode all inserts - skip xrefs.
(defun c:xpAll (/ doc mspace blockflag)


(setq doc (vla-get-ActiveDocument (vlax-get-acad-object)))
(setq mspace (vla-get-ModelSpace doc))

(setq blockflag t)
;;loop until no blocks are found.
(while blockflag
(setq blockflag nil)
(vlax-for x mspace
(cond
((and


(= "AcDbBlockReference" (vlax-get x 'ObjectName))
(not (vlax-property-available-p x 'Path))
)

;;if a block is found assume it might have a nested
;;block and loop again.
(setq blockflag t)
(vla-explode x)
(vla-delete x)
))))
(princ))


"Joe Burke" <job...@hawaii.rr.com> wrote in message news:41039f5b_1@newsprd01...


> Hi Doug,
>
> Check me. I think there's a problem with xpall when the drawing contains xrefs. It
> goes into an endless loop because the xrefs can't be exploded. But of course they
> continue to be added to ss within the while loop based on the "insert" filter.
>

<snip>


Joe Burke

unread,
Jul 25, 2004, 10:32:06 PM7/25/04
to
Doug,

That's mo' better. :-)

I modified a bit to operate in the active space. I think that's what I would want it
to do. But maybe it should explode all in model and paper space. What do you think?

Joe Burke

;;A program by Joe Burke with changes by D.C. Broad

;;Explode all inserts in the current space - skip xrefs.
(defun c:xpAll (/ doc space blockflag)
(setq doc (vla-get-ActiveDocument (vlax-get-acad-object)))
(if (= 1 (vlax-get doc 'ActiveSpace))
(setq space (vla-get-ModelSpace doc))
(setq space (vla-get-PaperSpace doc))


)
(setq blockflag t)
;;loop until no blocks are found.
(while blockflag
(setq blockflag nil)

(vlax-for x space


(cond
((and
(= "AcDbBlockReference" (vlax-get x 'ObjectName))
(not (vlax-property-available-p x 'Path))
)
;;if a block is found assume it might have a nested
;;block and loop again.
(setq blockflag t)
(vla-explode x)
(vla-delete x)
))))
(princ)

) ;end

> Great points Joe. I overlooked xrefs. Oops.
> Looked at your program and made a few changes. What
> do you think?

> snip


Message has been deleted

msa...@gmail.com

unread,
Jan 25, 2013, 11:30:20 AM1/25/13
to Joe Burke
Hello everybody.
This is the first time I am in this forum. I just test the routine and it is very good. Its is also very fast and explodes all levels of nested blocks.
I have just two questions:

1.When I explode a block made in layer 0 with color and linetype BYBLOCK, it reverses to layer 0 with color and linetype BYBLOCK and I would like to avoid this. I would like to keep the layer, the color and the linetype as the same as it had when it was a block. Is that possible?

2.After the blocks were explode, all the hatch boundary associativity were remove and bring to front, as well as the wipeouts were bring to front. It hides what's behind. It is possible to avoid this? I mean, I do not want send them to back after explode the block, I just want to keep its position as they were in the block.

Last thing, I would like to operate in both model and papers space at one shot

Thanks for any help!
Marcelo
Reply all
Reply to author
Forward
0 new messages