Well, I don't have a drawing handy with a number of Dynamicblocks, both altered & unaltered, with a mix of standard blocks, so I can't properly test this at the moment. But here are the two methods I described previously.
(defun ssDynBlk1 (/ ent fltrlist fltrstring idx ss)
(setq fltrstring "`*U*")
(vlax-for x (vla-get-blocks
(vla-get-activedocument
(vlax-get-acad-object)))
(if (and (eq (vla-get-IsLayout x) :vlax-false)
(eq (vla-get-IsDynamicBlock x) :vlax-true)
)
(setq fltrstring (strcat fltrstring "," (vla-get-name x)))
)
)
(if (setq ss (ssget "x" (list '(0 . "INSERT") (cons 2 fltrstring))))
(progn
(setq idx 0)
(while (setq ent (ssname ss idx))
(if (eq (vla-get-isdynamicblock (vlax-ename->vla-object ent)) :vlax-false)
(ssdel ent ss)
(setq idx (1+ idx))
)
)
)
)
ss
)
(defun ssDynBlk2 (/ ent fltrlist fltrstring idx ss1 ss2)
(vlax-for x (vla-get-blocks
(vla-get-activedocument
(vlax-get-acad-object)))
(if (and (eq (vla-get-IsLayout x) :vlax-false)
(eq (vla-get-IsDynamicBlock x) :vlax-true)
)
(if (not fltrstring)
(setq fltrstring (vla-get-name x))
(setq fltrstring (strcat fltrstring "," (vla-get-name x)))
)
)
)
(if fltrstring
(setq ss1 (ssget "x" (list '(0 . "INSERT") (cons 2 fltrstring))))
)
(or ss1
(setq ss1 (ssadd))
)
(if (setq ss2 (ssget "x" (list '(0 . "INSERT") (cons 2 "`*U*"))))
(progn
(while (setq ent (ssname ss2 0))
(if (eq (vla-get-isdynamicblock (vlax-ename->vla-object ent)) :vlax-true)
(ssadd ent ss1)
)
(ssdel ent ss2)
)
)
)
ss1
)