As they are dynamic blocks, any block references (inserts) where a dynamic property has be activated will be anonymous i.e. the block name will be something like *U????, and it is not possible to filter using the blocks effective name (real name). IMHO it is best to select all blocks and then filter out only those blocks you require whilst processing as non dynamic blocks with attributes can also be anonymous.
Basic concept is
Code:
(setq blockfilter "MYBLOCK*"); this filter set for any block whose effective name starts with MYBLOCK (upper case as wcmatch is case sensitive)
(setq ss (ssget "_X" '((0 . "INSERT"))))
(cond (ss
(repeat (setq cnt (sslength ss))
(setq obj (vlax-ename->vla-object (setq ent (ssname ss (setq cnt (1- cnt))))))
(cond ( (wcmatch (strcase (valx-get obj 'effectivename)) blockfilter) ;filter out only those blocks that match the filter
;option 1 do your stuff here, or convert to list for further processing
)
;option 2 to remove non matching blocks from selection set result in a selection set (ss) of matching blocks
;(t
; (ssdel ent ss)
;)
)
)
)
)
You have two options
option 1 process only those blocks that match. Best as you only iterate the selection set once
option 2 remove non matching blocks from selection set. You will then need to process the resultant selection set again