Jump to content

SSGET - BLOCK, then Explode


GregGleason

Recommended Posts

I want to capture entities on a particular layer in a region and this does it correctly. I then want to explode the block. The command to explode it is not working.

 

Below is a screen shot of one of the blocks that should be exploded when the process has finished.

 

attachment.php?attachmentid=63569&cid=1&stc=1

(defun C:DTT ( / SS nm nms enx e )
 (if (setq SS (ssget "_C" '(7.244 2.071) '(16.665 10.003) '((0 . "TEXT,INSERT"))))
   (foreach enx (mapcar 'entget (vl-remove-if 'listp (mapcar 'cadr (ssnamex SS))))
     (or 
       (and
         (vl-every '(lambda (x) (member x enx)) '((0 . "TEXT")(8 . "DIMLDR")))
         (entmod (subst '(8 . "TEXT") '(8 . "DIMLDR") enx))
       ); and 
       (and 
         (member '(0 . "INSERT") enx)
         (setq nm (vla-get-EffectiveName (vlax-ename->vla-object (cdr (assoc -1 enx)))))
         (not (member nm nms))
         (setq nms (cons nm nms))
         (setq enx (entget (tblobjname "BLOCK" nm)))
         (princ "\n                       Hey!")(princ)
         (princ (strcat " nm: " nm))(princ)
         (setq e (cdr (assoc -2 enx)))
         (while (and e (not (member '(0 . "SEQEND") (setq enx (entget e)))))
           (and (member '(0 . "TEXT") enx) (entmod (subst '(8 . "TEXT") (assoc 8 enx) enx)))
           (setq e (entnext e))
         ); while
         [color=red](command "explode" nm )[/color]
       ); and
     ); or
   ); foreach   
   (alert "\nNo selection.")
 ); if SS
 (if nms (vla-Regen (vla-get-ActiveDocument (vlax-get-acad-object)) acActiveViewport))
 (princ)
); defun 
(vl-load-com) (princ)

Attached is a sample drawing with 3 blocks that should be exploded.

 

Greg

EAE_3.jpg

Test3.DWG

Link to comment
Share on other sites

Because the while loop evaluates nil, so just try wrapping with progn function.

 

I don't quite understand what you mean.

 

I somewhat understand that you can use progn to expand the area where a particular condition exists, so I at least understand that. I understand how it is used in this setting:

 

    (if (equal out1 out2)
      (princ "\nYES!!")
      (progn
         (princ "\nno.")
         (princ "\n ------------------------------------------------")
         (princ "\n")
         (princ out1)
         (princ "\n ------------------------------------------------")
         (princ "\n")
         (princ out2)
         (princ "\n ------------------------------------------------")
      )
   )
 

 

Is this somewhat along the lines of what you mean?

 

Greg

Link to comment
Share on other sites

Kinda, although now rechecking the code iterates over the unique block definitions.

Also the explode command expects a selection set, which in your case should contain the block reference's ename.

So thats the real problem, not that the and evaluation 'would stop' after the while function finished.

Link to comment
Share on other sites

So, do I need to add another variable and then use that to explode the blocks?

 

I'm not sure what the next step is.

 

Greg

Link to comment
Share on other sites

Thats the only step.

So determine what part of the code iterates over the selection set and try to guess what should be the block reference variable inside that loop.

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