(vla-ConvertToStaticBlock (vlax-ename->vla-object (car (entsel))) "NewName")
(vla-put-name x "NewName")
Just an example:Code: [Select](vla-ConvertToStaticBlock (vlax-ename->vla-object (car (entsel))) "NewName")
Be careful, that strategy will introduce errors unless all instances of a given block share the same state.Oh yeah, I wasn't thinking about that.
:) I remembered seeing it a while back when I wrote the routine that allows one to change the visibility states for multiple Dynamic blocks at once.Just an example:Code: [Select](vla-ConvertToStaticBlock (vlax-ename->vla-object (car (entsel))) "NewName")
That's a new one for me thanks Alan :-)
(defun c:UnDynamic
( /
_get_item
_right
_make_key
_dynamic->static_block
_get_locked
_get_dynamic_inserts
_main
)
(defun _get_item ( collection key / item )
(vl-catch-all-apply
'(lambda ( ) (setq item (vla-item collection key)))
)
item
)
(defun _right ( str n / len )
(if (< n (setq len (strlen str)))
(substr str (1+ (- len n)))
str
)
)
(defun _make_key ( collection prefix len / key )
( (lambda ( i pad )
(while
(_get_item collection
(setq key
(strcat prefix
(_right
(strcat pad (itoa (setq i (1+ i))))
len
)
)
)
)
)
key
)
0
( (lambda ( pad )
(while (< (strlen pad) len)
(setq pad (strcat "0" pad))
)
pad
)
""
)
)
)
(defun _dynamic->static_block ( blocks insert len )
(vla-ConvertToStaticBlock
insert
(_make_key blocks "STATIC_" len)
)
)
(defun _get_locked ( layers / locked )
(vlax-for layer layers
(if (eq :vlax-true (vla-get-lock layer))
(setq locked (cons layer locked))
)
)
locked
)
(defun _get_dynamic_inserts ( blocks / inserts )
(vlax-for block blocks
(vlax-for object block
(if (eq "AcDbBlockReference" (vla-get-objectname object))
(if (eq :vlax-true (vla-get-isdynamicblock object))
(setq inserts (cons object inserts))
)
)
)
)
inserts
)
(defun _main ( document / blocks inserts locked len )
(if
(setq inserts
(_get_dynamic_inserts
(setq blocks (vla-get-blocks document))
)
)
(progn
(foreach layer (setq locked (_get_locked (vla-get-layers document)))
(vla-put-lock layer :vlax-false)
)
(setq len (strlen (itoa (length inserts))))
(foreach insert inserts
(_dynamic->static_block blocks insert len)
)
(foreach layer locked
(vla-put-lock layer :vlax-true)
)
)
)
(princ)
)
(_main (vla-get-activedocument (vlax-get-acad-object)))
)
Friday quick & dirty freebie ... not the most efficient but free ...Alan is right, you really are an artist. Nice work.
Friday quick & dirty freebie ... not the most efficient but free ...Alan is right, you really are an artist. Nice work.
(defun c:delinvb (/ acdoc ss i sset nme Blockdefinition)
(vl-load-com)
(setq acdoc (vla-get-activedocument
(vlax-get-acad-object)
)
)
(if (setq ss (ssget "_:L" '((0 . "INSERT"))))
(repeat
(setq i (sslength ss))
(setq sset (ssname ss (setq i (1- i))))
(setq nme (cdr (assoc 2 (entget sset))))
(setq Blockdefinition (vla-item (vla-get-blocks acdoc) nme))
(if
(and
(eq :vlax-false (vla-get-isxref Blockdefinition))
(eq :vlax-false (vla-get-islayout Blockdefinition))
)
(vlax-for x Blockdefinition
(if(=(vla-get-Visible x) :vlax-false)
(vla-delete x)
)
)
)
)
(princ)
)
(vla-regen acdoc acAllViewports)
(princ)
)
Friday quick & dirty freebie ... not the most efficient but free ...
(_make_key blocks "STATIC_" len)
was changed to(_make_key blocks (strcat (vla-get-EffectiveName insert) "_") len)
(foreach insert inserts
(_dynamic->static_block blocks insert len)
)
was changed to(foreach insert inserts
(if (null (wcmatch (vla-get-name insert) "*|*"))
(_dynamic->static_block blocks insert len)
)
)
Are there any workaround for this in the MAC platform?
Hi AllHere you go .. welcome to TheSwamp :) . be aware that the code does not checked for locked layers.
These lisps are brilliant!! Has anyone created / found a lisp that will take the UNDYNAMIC in a slightly different direction?
I have 400 drawings that contain Dynamic blocks that use the visibility method. I need to lobotomize the blocks at a global level but ensure that the end product is the block renamed to include the visibility state convention. i.e. BlockName_VisibilityState.
Can anyone help?
Nice one Ron - though, unfortunately I don't believe that you can rely on the Property Name of the Visibility State parameter being named "Visibility", since any dynamic block parameter may be arbitrarily named.Ah yes .. silly me :)
Dynamic Block functions from here (http://lee-mac.com/dynamicblockfunctions.html).
Friday quick & dirty freebie ... not the most efficient but free ......and then 6 years later, stolen and presented without credit.
Happens tons (here and out there), one of many reasons why I basically stopped posting code.
That said, the author of that site is a complete <pick derogatory word>.
have dynamic blocks really been around 6 years? (where does time go?)Quote from: MPFriday quick & dirty freebie ... not the most efficient but free ......and then 6 years later, stolen and presented without credit.
https://lispbox.wordpress.com/2016/02/29/undinamic-all-blocks-in-one-click/ (https://lispbox.wordpress.com/2016/02/29/undinamic-all-blocks-in-one-click/)
have dynamic blocks really been around 6 years?
Friday quick & dirty freebie ... not the most efficient but free ...Code: [Select](defun c:UnDynamic
)