Jump to content

explode blocks


daisenson

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 }

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

 
(defun c:440 ()
(ssget "x" '((0 . "insert")(8 . "440_xref")))
(command "explode" "p" "")
)

 

Are you trying to explode xrefs? -David

Link to comment
Share on other sites

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.

Link to comment
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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

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