This creates a selectionset ss for you to use like : (sslength ss) or on command line : erase (eval ss) etc
(defun c:test ( / r)(if (vl-consp (setq r (get)))(progn (setq ss (ssadd))(foreach e r (ssadd e ss)))))
(defun get ( / s l) (if (setq s (ssget))
(foreach e (mapcar 'cadr (ssnamex s))(if (ggn e)(progn (redraw e 3)(setq l (cons e l)))))) l)
(defun ggn (o / m g) (setq g (vla-get-groups (vla-get-activedocument (vlax-get-acad-object))))
(if (= (type o) 'ENAME) (setq o (vlax-ename->vla-object o)))
(vlax-for x g (vlax-for y x (if (equal o y)(setq m (cons (vlax-get x 'Name) m))))) m)