Do you get sooo frustrated when you see you're users EXPLODING your nice Dynamic blocks? Yes, there is the option that allows you to specify which blocks can be exploded. But face it, sometimes you have to. There is options where a block needs to be a totally different layer, or color or linetype. I run into this all the time. But I may have a solution for this.
If you use the attached code called MAKE0, it prompts you to select a block, dynamic or not. It will next take that block and create a block with the same block name but with the extension -0. Then change all the objects in the block from its current layers and settings to layer 0. It will erase the old block and insert the new block in the same location. Once placed, the block will get the same settings in the currently set layer for the drawing. Allowing you to change the appearance of you blocks without having to explode them.
Here you select the block.
Next your block will get the current layers properties applied to it.
Now your block is still a block and will change as you change its layer settings.
Here the block changes as you change its current layer.
Now for the code!!
Note: Dynamic blocks wont be set back to their dynamic block states. It will act just like a reset. You will also notice a quick flash when the code enters the dynamic block editor. This is needed to retain the dynamic block properties.
(defun c:make0 (/ oldblk oldblkname oldblkX
oldblkY oldblkZ oldblkrot newblkname
)
(setvar "osmode" 0)
(setvar "blockeditlock" 0)
(setq oldblk (entsel "\nSelect Block for Zero Makeover: "))
(setq oldblkname (vla-get-EffectiveName (vlax-ename->vla-object (car oldblk))))
(setq oldblkins (cdr (assoc 10 (entget (car oldblk)))))
(setq oldblkX (cdr (assoc 41 (entget (car oldblk)))))
(setq oldblkY (cdr (assoc 42 (entget (car oldblk)))))
(setq oldblkZ (cdr (assoc 43 (entget (car oldblk)))))
(setq oldblkrot (cdr (assoc 50 (entget (car oldblk)))))
(setq newblkname (strcat "0-" oldblkname))
(if (= (tblsearch "block" newblkname) nil)
(setq testflag 0)
(setq testflag 1)
)
(if (= testflag 0)
(progn
(COMMAND "-BEDIT" oldblkname)
(command "bsaveas" (strcase (strcat "0-" oldblkname)))
(command "change" "all" "" "p" "la" "0" "")
(command "bsave")
(command "bclose")
(command "erase" oldblk "")
))
(command "erase" oldblk "")
(command "insert"
newblkname
oldblkins
oldblkX
oldblkY
(/ (* 180 oldblkrot) pi)
)
(gc)
(princ)
)
Mark, does this alter the insertion point at all? I have one called BL0 that I found a while back, and for some reason when the UCS isnt World, it alters the position the block was in.
Posted by: Steven D. Papke | November 19, 2005 at 08:34 AM
hey...intersting...copy paste;)
Posted by: Professional web design Specialist | November 22, 2005 at 05:00 AM
Is there a way to join the objects together after you explode them? that way when you click on it, it is joined as one object?
Posted by: Lee | October 05, 2006 at 06:21 AM