GregGleason Posted March 22, 2018 Share Posted March 22, 2018 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. (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 Test3.DWG Quote Link to comment Share on other sites More sharing options...
Grrr Posted March 22, 2018 Share Posted March 22, 2018 Because the while loop evaluates nil, so just try wrapping with progn function. Quote Link to comment Share on other sites More sharing options...
GregGleason Posted March 22, 2018 Author Share Posted March 22, 2018 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 Quote Link to comment Share on other sites More sharing options...
Grrr Posted March 22, 2018 Share Posted March 22, 2018 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. Quote Link to comment Share on other sites More sharing options...
GregGleason Posted March 22, 2018 Author Share Posted March 22, 2018 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 Quote Link to comment Share on other sites More sharing options...
Grrr Posted March 22, 2018 Share Posted March 22, 2018 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. 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.