daisenson Posted October 10, 2010 Share Posted October 10, 2010 Hi everyone, I'm trying to explode some blocks in one layer with the following code (defun c:440 () (ssget "x" '((0 . "insert")(8 . "440_xref"))) (command "explode" "p" "") ) I get the following error: Command: 440 explode Select object: p *Invalid selection* Expects a point or Last/ALL/Group ; error: Function cancelled I know it's a fairly simple action and I've even tried it with a scrip (using ssx) but when explode tries to get the previous selection it doesn't recognize it. Any ideas what's going on? thanks Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted October 10, 2010 Share Posted October 10, 2010 You may need to use something like this: (defun c:440 ( / *error* ss qf ) (defun *error* ( msg ) (and qf (setvar 'QAFLAGS qf)) (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*") (princ (strcat "\n** Error: " msg " **"))) (princ) ) (if (setq ss (ssget "_X" '((0 . "INSERT") (8 . "440_xref")))) (progn (setq qf (getvar 'QAFLAGS)) (setvar 'QAFLAGS 5) (command "_.explode" ss "") (setvar 'QAFLAGS qf) ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted October 10, 2010 Share Posted October 10, 2010 Or, using VL: (defun c:440 ( / ss ) (vl-load-com) (if (ssget "_X" '((0 . "INSERT") (8 . "440_xref"))) (progn (vlax-for o (setq ss (vla-get-ActiveSelectionSet (vla-get-ActiveDocument (vlax-get-acad-object) ) ) ) (if (not (vl-catch-all-error-p (vl-catch-all-apply 'vla-explode (list o)) ) ) (vla-delete o) ) ) (vla-delete ss) ) ) (princ) ) { Untested } Quote Link to comment Share on other sites More sharing options...
daisenson Posted October 10, 2010 Author Share Posted October 10, 2010 I gather that QAFLAGS is the missing link in my script (still trying to figure out what they are, although I gather that they prevent the script from selecting more than 1 object at the time) Doing a bit of reading, some say qaflags should be in 1, but on your script and in another thread I read 5. Any difference? Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted October 10, 2010 Share Posted October 10, 2010 I gather that QAFLAGS is the missing link in my script (still trying to figure out what they are, although I gather that they prevent the script from selecting more than 1 object at the time)Doing a bit of reading, some say qaflags should be in 1, but on your script and in another thread I read 5. Any difference? Both should work, bit-4 suppresses alert boxes also. Quote Link to comment Share on other sites More sharing options...
VVA Posted October 11, 2010 Share Posted October 11, 2010 Small addition I gather that QAFLAGS is the missing link in my script (still trying to figure out what they are, although I gather that they prevent the script from selecting more than 1 object at the time) From the help about command Explode Note: If you're using a script or an ObjectARX® function, you can explode only one object at a time. (defun c:440 ( / *error* ss qf i ) (defun *error* ( msg ) (and qf (setvar 'QAFLAGS qf)) (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*") (princ (strcat "\n** Error: " msg " **"))) (princ) ) (if (setq ss (ssget "_X" (list '(0 . "INSERT")'(8 . "440_xref")(cons 410 (getvar "CTAB"))))) (progn (setq qf (getvar 'QAFLAGS)) (setvar 'QAFLAGS 5) (setq i '-1) (repeat (sslength ss) (command "_.explode" (ssname ss (setq i (1+ i))) "") ) (setvar 'QAFLAGS qf) ) ) (princ) ) VLA-explode method does not explode block with different scales in x, y, z Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted October 11, 2010 Share Posted October 11, 2010 Temporarily changing the setting of QAFLAGS should allow a SelectionSet to be exploded without having to set through the set, does it not? Thanks for the catch with vla-explode Quote Link to comment Share on other sites More sharing options...
David Bethel Posted October 11, 2010 Share Posted October 11, 2010 (defun c:440 () (ssget "x" '((0 . "insert")(8 . "440_xref"))) (command "explode" "p" "") ) Are you trying to explode xrefs? -David Quote Link to comment Share on other sites More sharing options...
alanjt Posted October 11, 2010 Share Posted October 11, 2010 Small addition From the help about command Explode (defun c:440 ( / *error* ss qf i ) (defun *error* ( msg ) (and qf (setvar 'QAFLAGS qf)) (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*") (princ (strcat "\n** Error: " msg " **"))) (princ) ) (if (setq ss (ssget "_X" (list '(0 . "INSERT")'(8 . "440_xref")(cons 410 (getvar "CTAB"))))) (progn (setq qf (getvar 'QAFLAGS)) (setvar 'QAFLAGS 5) (setq i '-1) (repeat (sslength ss) (command "_.explode" (ssname ss (setq i (1+ i))) "") ) (setvar 'QAFLAGS qf) ) ) (princ) ) VLA-explode method does not explode block with different scales in x, y, z If you are stepping through the selection set and exploding each entity individually, you don't need to worry with QAFlags. Quote Link to comment Share on other sites More sharing options...
VVA Posted October 12, 2010 Share Posted October 12, 2010 Thank alanjt that drew my attention. Added this technique to his piggy bank. I will add that to the command _explode there is a system variable EXPLMODE Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.