Recursive explode needs selection option
I borrowed a recursive explode lisp (from user hmsilva on another forum). It works very well to explode all blocks inc nested. Right now it works on the whole drawing though and I was hoping it could be made to work only on a window selection. I'm not familiar with lisp programming yet so have no idea where to start. Could someone point me in the right direction?
thanks...
Scott
Comments
-
please post the lisp.
0 -
-
Any ideas out there on how to go about this? I want to make a copy of certain blocks in the dwg, and explode only those - not the originals.
thanks0 -
I haven't downloaded an read your LISP file. You might get better forum answers by copy-pasting the code if it's not too long.
But from a process point of view, the lisp you have is either iterating through all the blocks, or selecting all blocks in the drawing.
Either way on each of those blocks, it's running it's explode command.Your goal is is to have the user select blocks, then run that same code. I'd look into SSGET
Then you just need to replace the outer iteration in the code you have with what you got from the SSGET.
0 -
@Atook
Right, the current code loops through all blocks in the drawing, using (setq ss (ssget "_X" '((0 . "INSERT"))))
Lets try just changing that to (setq ss (ssget '((0 . "INSERT"))))
try the attached revised lisp - in next post, forgot it on this.0 -
-
Here is my version:
(defun KGA_Conv_Pickset_To_ObjectList (ss / i ret) (if ss (repeat (setq i (sslength ss)) (setq ret (cons (vlax-ename->vla-object (ssname ss (setq i (1- i)))) ret)) ) ) ) ; Recursively explodes a selection of block references. (defun c:FullExpl ( / N_Explode doc lst lyrLckLst new ss) (defun N_Explode (ref / lst new) (if (and (not (vl-position (strcase (vla-get-layer ref)) lyrLckLst)) ; Exclude locked layers. (not (vlax-property-available-p ref 'path)) ; Exclude xrefs. (setq lst (vlax-invoke ref 'explode)) ; Lst will be nil if ref is not explodable. ) (progn (vla-delete ref) (foreach obj lst (if (= "AcDbBlockReference" (vla-get-objectname obj)) (setq new (cons obj new)) ) ) new ) ) ) (setq doc (vla-get-activedocument (vlax-get-acad-object))) (vla-endundomark doc) (vla-startundomark doc) (if (setq ss (ssget "_:L" '((0 . "INSERT")))) (progn (setq lyrLckLst (vl-remove nil (mapcar '(lambda (lyr) (if (= :vlax-true (vla-get-lock lyr)) (strcase (vla-get-name lyr)) ) ) (vle-collection->list (vla-get-layers doc)) ) ) ) (setq lst (KGA_Conv_Pickset_To_ObjectList ss)) (while lst (foreach ref lst (setq new (append (N_Explode ref) new)) ) (setq lst new) (setq new nil) ) ) ) (vla-endundomark doc) (princ) )
0 -
Thanks all - I appreciate the help. Roy I found yours worked best for me since it was recursive and I had to select just once. I'll try to see the difference in the code so I can learn for the future.
Cheers all0 -
oh, right, the original is not recursive. Guess I just put lipstick on a pig
0 -
@James Maeding
The original (as posted on Dec 17th) is recursive.0 -
@Roy Klein Gebbinck said:
The original (as posted on Dec 17th) is recursive.But only because of the (ssget "X")?
0 -
Oh, I did not look close enough at the code.
My switch to ssget is no good at all for the purposes at hand, you would be selecting stuff in each loop as mentioned.
@Roy Klein Gebbinck code wins!0 -
-
@Roy Klein Gebbinck
indeed, I missed that too. We need to loop through the items in the block and keep digging and exploding.
I have tools to do that for making things bylayer, I'll adjust to explode, like weaponizing a poor innocent lisp.0 -
Maybe I need to explain better.
My code will give the desired result: It will explode a selection of block references and check the resultant objects for occurrences of block references and explode those etc. But technically speaking the code is iterative.0