Can anyone tell me why this script isn't working?

Can anyone tell me why this script isn't working?

evannB2AWD
Enthusiast Enthusiast
255 Views
3 Replies
Message 1 of 4

Can anyone tell me why this script isn't working?

evannB2AWD
Enthusiast
Enthusiast

(defun c:1234 ()
(command "_.explode" (ssget "_A"))
(princ "\n...test...")
(princ))

 

I am using this line as part of a larger routine. The routine isolates a bunch of cogo points and blocks, and I want to select all non-frozen objects, and explode them. When I run this same script to erase all, it works. But for whatever reason- the explode feature doesn't work. It will either only explode one thing, or tell me nothing can be exploded. Even though there are blocks and polylines on my screen that it's not catching. 

0 Likes
256 Views
3 Replies
Replies (3)
Message 2 of 4

ВeekeeCZ
Consultant
Consultant

(defun c:1234 ()

(initcommandversion)
(command "_.explode" (ssget "_A") "")
(princ "\n...test...")
(princ))

 

A lisp version of EXPLODE does not support selection sets....

Message 3 of 4

paullimapa
Mentor
Mentor

2 ways :

 

(setvar 'qaflags 1)

(vl-cmdf "_.explode" ss)

(setvar 'qaflags 0)

 

But working with QAFLAGS is little risky - if not reset to 0, CAD behaves strange...

 

(initcommandversion)

(vl-cmdf "_.explode" ss)

 

https://www.cadtutor.net/forum/topic/76623-explode-command-does-not-work-with-selection-window-help/

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 4 of 4

cadffm
Consultant
Consultant

 

 

Hi evannB2AWD,

 

small correction

(initcommandversion)

(vl-cmdf "_.explode" ss "") or (vl-cmdf "_.explode" (ssget "_A") "")

 

 

>>"The routine isolates a bunch of cogo points and blocks,"


; 1. on thawed layer, 2. in current space, 3.Inserts&CogoPoints - only
(if (ssget "_A" (list'(0 . "INSERT,AECC_COGO_POINT")(cons 410 (getvar 'CTAB))))
     (progn(initcommandversion)(command "_.explode" "_p" ""))
)

 

But it's not safe enough - think about Xrefs=INSERT and Arrays for example,
and INSERT+AECC_COGO_POINT on LOCKED Layers - (ssget "_A") will select all of them.

 

 

 

>>"It will either only explode one thing," & "Can anyone tell me why this script isn't working?"

A lisp version of EXPLODE does not support selection sets....

 

A bit more explained:

There are some differences in the automated use of AutoCAD commands compared to manual operation.
So in MenuMacros, Scripts.scr and (send)command -statements

For example, AutoCAD ignores the FileDia setting and automatically uses the command line version (like FileDia=0).
Unfortunately, AutoDESK has only managed to implement this rule for 99% of the commands, but I think that's enough to describe it as a rule.

In addition, there are commands that have been in AutoCAD for a very long time and previously existing commands were also controlled automatically.
What happens when Autodesk changes the command options? Exactly, the old codes, the (Command instructions would no longer work.
For this reason, AutoDESK has, unfortunately not always, stored different command versions in the program.
A particularly interesting example is INSERT, and +100 other commands.

 

So let's stick with your simple case: Explode

At the very beginning, Explode could only explode one object,
later you could explode several objects at once.
Explode Objectselection <Enter> So (Command "_EXPLODE" (SSGET) "")
This would mean that the old codes would no longer work, because the Explode command waits for the completion of the object selection, the final ENTER

Solution: The original command is still used in automations,
this only expects an input of an object, not a subsequent Enter.

Since 2009, you can also use other versions of the command, if available.
This is controlled via initcommandversion (and in MenuMacros ^R)

 

Funfact: Your sample, the explode command,  it the only one(?) what is documented like that!
So if you had read the help about this command, you had answered your question yourself:

 

>Note: If you're using a script or an ObjectARX® function, you can explode only one object at a time...

 

But of course, you had to know that "Script" means all kins of scripting, menumacro,script,(send)command

 

 

HTH to understand this and other "issues" with the control of native commands,

instead of using a custom function that produces the desired result.

 

 

Sebastian

0 Likes