AutoCAD Core Console: Simple script will not explode all blocks in drawing

AutoCAD Core Console: Simple script will not explode all blocks in drawing

Anonymous
Not applicable
1,133 Views
4 Replies
Message 1 of 5

AutoCAD Core Console: Simple script will not explode all blocks in drawing

Anonymous
Not applicable

I am using AutoCAD Core Console to run a script via batch file to explode all blocks in a folder of AutoCAD drawing (DWG) files.

 

Batch file

FOR %%f IN ("%~dp0*.dwg") DO "C:\Program Files\Autodesk\AutoCAD 2021\accoreconsole.exe" /i "%%f" /s "%~dp0scripts\explode.scr" /l en-US

Script

EXPLODE
ALL
QSAVE

 

The above commands will explode ALL objects when executed in the AutoCAD UI, but the script will only explode one block per drawing leaving the rest of the blocks intact. Any ideas where I'm going wrong?

0 Likes
Accepted solutions (1)
1,134 Views
4 Replies
Replies (4)
Message 2 of 5

Sea-Haven
Mentor
Mentor

A check that your in correct space may be good, guess all in Model so maybe script like this, note the blank line is to end explode choice. Also check even though "All" still needs a return to cancel selection.

 

 

(setvar 'ctab "Model")
(setq ss (ssget "X" '((0 . "INSERT"))))
explode !ss

qsave

 

 

 

0 Likes
Message 3 of 5

Anonymous
Not applicable

A good idea. However, it still only explodes one block.

 

It's a shame core console can't run EXPLODE>ALL the same as Autocad UI does.

 

Do I need to make the script recursive?

0 Likes
Message 4 of 5

Kent1Cooper
Consultant
Consultant
Accepted solution

@Anonymous wrote:

.... it still only explodes one block. ....


The Explode command has the same limitation when used in an AutoLisp (command) function.  It can be overcome by setting the mysterious QAFLAGS System Variable to 1 first, and ensuring that it gets reset to 0 afterwards [because if not, it can cause other problems].  Search this Forum for examples.  Maybe the same can be done in your Script to allow Exploding multiple objects at once.

Kent Cooper, AIA
0 Likes
Message 5 of 5

Anonymous
Not applicable

@Kent1Cooper brilliant. That did the trick, thankyou!

0 Likes