It looks like you're new here. If you want to get involved, click one of these buttons!
Having played around with Dynamic Blocks I have discovered (along with many others) that you can no longer simply rely on (ssget "X" '((cons 2. "blockname"))) in Lisp to find all the blocks of a particular name on your drawing.
Dynamic blocks use anonymous blocks *U* to replace the default instance of the block with the modified version. This stops (ssget "X" '((cons 2. "blockname"))) from working, as you need to know the anonymous block name, not the original block name.
This raises a number of problems for LISP users (not sure about other environments) as functions that look for blocks using ssget won't necessarily find them, and there doesn't appear to be any way with standard LISP to determine whether a block is Dynamic or not.
I have created the function below to return a selection set of blocks of the same name in a drawing. Works in two passes.
; Function to create a selection set of standard & dynamic blocks
; That have the same Effective name
(defun BlockSSET (blname / sset ss-dyn num ent effname)
(vl-load-com) ; ensure that ActiveX is loaded.
(if (not (setq sset (ssget "X" (list (cons 2 blname))))) ; Select block with standard method. This will also capture dynamic blocks in their default state.
(setq sset (ssadd)) ; if nothing is found then create and empty selection set
(if (setq ss-dyn (ssget "X" (list (cons 2 "`*U*")))) ; select all anonymous blocks. this will also capture any dynamic blocks that have been worked with
(progn ; If anonymous blocks found, check for the given effective name
(setq num 0) ; zero counter
(repeat (sslength ss-dyn) ; repeat for the number of objects in the selection set
(setq ent (ssname ss-dyn num)) ; find the entity name
(setq effname (vla-get-EffectiveName (vlax-ename->vla-object ent))) ; Find the EffectiveName of the block
(if (= blname effname) ; if the blockname matches the effective name
(ssadd ent sset) ; then add it to the original selection set
); end if
(setq num (1+ num)) ; Increment the counter by one
; return the gathered selection set
Seems to work ok. Would be interested in seeing how others have approached this problem. Dynamic blocks are a useful feature to have, but you need to be able to work with them easily.
Note also in Bricscad that Quickselect will not work with Dynamic blocks, assume for the same reason. Also when you list a Dynamic Block it returns the anonymous name, but doesn't give the effective name.