Script Problem

Script Problem

BIMadmin
Enthusiast Enthusiast
2,599 Views
15 Replies
Message 1 of 16

Script Problem

BIMadmin
Enthusiast
Enthusiast

Hello Community,

 

I am very new on Scripting, (.scr)

 

I have been trying to create a very simple one but I cannot manage to get it work

 

I need to:

 

SELECT ALL IN MODEL

EXPLODE

DELETE LAYOUT 2

SAVE

 

Any help will be really appreciated!!!

0 Likes
2,600 Views
15 Replies
Replies (15)
Message 2 of 16

M_Hensley
Advisor
Advisor

Try this in your script file:

 

EXPLODE

ALL

 

LAYOUT

D

LAYOUT2

QSAVE

 

0 Likes
Message 3 of 16

BIMadmin
Enthusiast
Enthusiast

Thank you very much for your prompt answer the layout deletion seems to work GREAT, however I need to explode some blocks and hatches and they do not get exploted, smileyfrustrated:

 

I need to purge as well and this does not work either...don't understand

 

Thanks for the support

0 Likes
Message 4 of 16

Kent1Cooper
Consultant
Consultant

@BIMadmin wrote:

.... I need to explode some blocks and hatches and they do not get exploted.....


I don't have any bright ideas about the Hatches, but [in new-enough versions] Blocks can be defined to not allow Exploding.  Might that be the case for any of yours?  You can change that property in the Block Editor if needed.

Kent Cooper, AIA
0 Likes
Message 5 of 16

M_Hensley
Advisor
Advisor

Try putting a period in front of the explode command to make sure you get the native command with no restrictions added.

 

.EXPLODE

0 Likes
Message 6 of 16

BIMadmin
Enthusiast
Enthusiast

 

HATCHES DO NOT GET EXPLODE NO IDEA WHY!!!

0 Likes
Message 7 of 16

BIMadmin
Enthusiast
Enthusiast

ALL THE BLOCKS HAVE ENABLED ALLOW EXPLODING,

WHEN I RUN THE COMMAND MANUALLY IT DOES WORK BUT MY SCR DOESN'T WORK

THE SAME FOR PURGE...

REALLY ANNOYING...

0 Likes
Message 8 of 16

pendean
Community Legend
Community Legend
Share with us your DWG file and point to the blocks that did not explode with your script.
0 Likes
Message 9 of 16

BIMadmin
Enthusiast
Enthusiast

Sure

 

Here is the .scr:

 

XPLODE
A

PURGE
A
N

LAYOUT
D
Layout2
QSAVE
QUIT

 

None of the blocks nor hatches are exploded

the purge command is not purging anything

 

I was trying to include overkill on it but it does not work either, no idea....

 

0 Likes
Message 10 of 16

pendean
Community Legend
Community Legend

XPLODE is not EXPLODE: two different commands in AutoCAD. is that the problem? Look both up in HELP.

 

See your file: should be totally destroyed except for splines.

0 Likes
Message 11 of 16

BIMadmin
Enthusiast
Enthusiast

true I have tried EXPLODE XPLODE .EXPLODE

None of them work...

Smiley Frustrated

0 Likes
Message 12 of 16

Kent1Cooper
Consultant
Consultant

@BIMadmin wrote:

.... 

XPLODE
A

PURGE

....


In addition to the XPLODE-vs.-EXPLODE issue, A is not an abbreviation for ALL in object selection as it is in PURGE.  It's for getting back into the Add mode if you have gone into Remove mode, but even if you haven't, A still just leaves you with the selection prompt as if you had.  You would need to spell out the word ALL.  And you would need a blank line [another Enter] as in your original Post, to complete the selection in the Explode command.

 

EDIT:  The script as shown in Post 9 does not show the blank line, but after I picked the POST button, before the screen changed, I noticed that the blank line does show in the Replying-to part at the bottom, so you obviously do have that in your Script, even if the website has somehow expunged it in Post 9.

Kent Cooper, AIA
0 Likes
Message 13 of 16

BIMadmin
Enthusiast
Enthusiast

Hello again,

 

I think that my problem is that I cannot explode hatches through a script or lsp, am I right???

0 Likes
Message 14 of 16

Kent1Cooper
Consultant
Consultant

@BIMadmin wrote:

.... 

I think that my problem is that I cannot explode hatches through a script or lsp, am I right???


You can, BUT:

 

I knew that you can't Explode more than one thing together with an Explode command in an AutoLisp (command) function -- it will do only one unless you go through some hoops [do a SEARCH for discussions about the undocumented "QAFLAGS" System Variable].  I didn't expect the same would be true in a Script, but in a quickie test, apparently it is!  I think you'll find that your Script Explodes one of the objects, though whether it's the latest one drawn, or the first one, or it chooses by some other criteria, I couldn't say.

 

You can change the QAFLAGS setting to let it Explode multiple objects at once, being sure to set it back again, or you can do a Lisp routine that will do it without changing that, by finding everything Explodable and stepping through the selection, Exploding them one at a time.  The latter is safer, because of the problems that can result if QAFLAGS doesn't get set back [again, see the threads you'll find with a Search], but I don't think it can be done in a Script -- it would require AutoLisp.  There are probably several Lisp routines on these Forums already that Explode multiple objects that way, and you would only need to adjust the way the selection is made to pick everything [or filter for just Explodable entity types, so it doesn't need to step through everything in the drawing].

 

Because [assuming you leave QAFLAGS alone] Explode within a (command) function does only one object, it does not want that extra Enter to complete the selection -- the allowable selection is complete with one entry.  That additional Enter is therefore extraneous, which may be what's causing your Purge command to fail, but look over the Command-line history -- it may be obvious.

Kent Cooper, AIA
0 Likes
Message 15 of 16

BIMadmin
Enthusiast
Enthusiast

Hello and thank you very much for your reply.

Can you explain me a bit what QAFLAGS command does?

I have read that the input can varies from 0 up to 32767 but what really does?

Thanks!!!

0 Likes
Message 16 of 16

Kent1Cooper
Consultant
Consultant

@BIMadmin wrote:

....

Can you explain me a bit what QAFLAGS command does?

....


I can't -- I only know its value [it's a System Variable, not a command] needs to be changed to be able to Explode more than one thing in a (command) function, and that it's very important to ensure it gets set back.  I think there are a few other special circumstances that need it changed, though I forget what they are.  But a Search of the Customization Forum will turn up more than you could ever want to know, from people who know more than I do about it.  It's not documented in Help, so I'm not sure how they know more about it....

Kent Cooper, AIA
0 Likes