Peter, I think you code is great & looking for another way to deal with the dynamic block names, I could only offer a variation of your method.
I suspect this version would be slower with a large number of blocks.
;; a variant to include dynamic blocks
;; retrurns only block names that have one block only in the dwg
(defun c:blkunique2 (/ ss lst itm result)
(and
(setq ss (ssget "x" (list (cons 0 "INSERT"))))
(setq lst (mapcar '(lambda (x)
(if (vlax-property-available-p x 'EffectiveName)
(vla-get-EffectiveName x)
(vla-get-Name x)
))
(mapcar 'vlax-ename->vla-object (mapcar 'cadr (ssnamex ss))))
)
(while (setq itm (car lst))
(setq len (length lst)
lst (vl-remove itm lst)
cnt (- len (length lst))
)
(if (= cnt 1)
(setq result (cons itm result)))
)
)
(vl-sort result '<)
)