You might be able to use a variation of the following:
Code:
;; ATTVIS LOCATES ALL BLOCK REFERENCES IN THE ACTIVE LAYOUT WHICH CONTAIN AN
;; ATTRIBUTE REFERENCE WITH A PARTICULAR TAG (T_G) STRING, AND SETS SAID
;; ATTRIBUTE REFERENCES TO EITHER INVISIBLE (YN = NIL) OR VISIBLE (YN /= NIL)
;; -> T_G CAN ALSO BE A LIST OF TAG STRINGS
(defun attvis (t_g yn / ACTBLK N-ATTLST N-ATTS TG-LST)
(vl-load-com)
(setq actblk (vlax-get-property
(vlax-get-property
(vlax-get-property
(vlax-get-acad-object)
'activedocument
); vlax-get-property
'activelayout
); vlax-get-property
'block
); vlax-get-property
tg-lst (cond ((= 'STR (type t_g)) (list (strcase t_g))); single string
((and (listp t_g)
(< 0 (length t_g))
(not (vl-member-if-not
'(lambda (a)
(= 'STR (type a))
); lambda
t_g
); vl-member-if-not
); not
); and
(mapcar 'strcase t_g)
); list of strings
(t nil)
); cond
); setq
(if tg-lst
(progn
(vlax-for n actblk
(if
(and
(= "AcDbBlockReference" (vlax-get-property n 'objectname))
(= 'safearray (type (setq n-atts (vlax-variant-value (vla-getattributes n)))))
(< 0 (vlax-safearray-get-u-bound n-atts 1))
(< 0 (length (setq n-attlst (vlax-safearray->list n-atts))))
); and
(foreach x n-attlst
(if (member (strcase (vlax-get-property x 'tagstring)) tg-lst)
(vlax-put-property x 'visible (if yn :vlax-true :vlax-false))
); if
); foreach
); if
); vlax-for
); progn
(prompt "\nInvalid Data ")
); if
(princ)
); defun