Jump to content
daisenson

explode blocks

Recommended Posts

daisenson

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

Share this post


Link to post
Share on other sites
Lee Mac

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)
)

Share this post


Link to post
Share on other sites
Lee Mac

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 }

Share this post


Link to post
Share on other sites
daisenson

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?

Share this post


Link to post
Share on other sites
Lee Mac
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.

Share this post


Link to post
Share on other sites
VVA

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

Share this post


Link to post
Share on other sites
Lee Mac

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 :)

Share this post


Link to post
Share on other sites
David Bethel
 
(defun c:440 ()
(ssget "x" '((0 . "insert")(8 . "440_xref")))
(command "explode" "p" "")
)

 

Are you trying to explode xrefs? -David

Share this post


Link to post
Share on other sites
alanjt
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.

Share this post


Link to post
Share on other sites
VVA

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

Share this post


Link to post
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...