Just doing something wrong with using OBDX still getting my head around using it. I think the limitation is in getting an object via a selection set. So a script approach may be the easiest way.
Give this a try two parts the doatts.lsp file which does the work, the c:doatts that makes the script to be run so need to load that first. That means 2 lisp files. Change the Acadtemp to your start directory, pick any dwg for directory name.
(defun c:doatts ( / fname files pre fo)
(setq fname (getfiled "Select a Dwg FILE" "d:\\Acadtemp" "dwg" 16)) ; chnage start directory name
(setq pre (car (fnsplitl fname)))
(setq files (vl-directory-files pre "*.DWG" 0))
(setq fo (open (setq fname (vl-filename-mktemp "" "" ".scr")) "w"))
(write-line "(command \"regen\")" fo)
(foreach file files
(write-line (strcat "Open " "\"" pre file "\"") fo)
(write-line "(load \"doatts\")" fo)
(write-line "(AH:doatts)" fo)
(write-line "close Y" fo)
)
(close fo)
(command "script" fname)
(vl-file-delete fname)
(princ)
)
Second lisp is the doatts
defun AH:doatts ( / ss obj atts att tname)
(setq ss (ssget "X" '((0 . "INSERT"))))
(repeat (setq x (sslength ss))
(setq obj (vlax-ename->vla-object (ssname ss (setq x (1- x)))))
(if (= (vlax-property-available-p obj 'hasattributes) T)
(progn
(setq atts (vlax-invoke obj 'Getattributes))
(foreach att atts
(setq tname (vlax-get att 'Tagstring))
(if (= tname "MATERIAL")
(vlax-put att 'Textstring "TEST")
)
)
)
)
)
(command "close" "Y")
(princ)
)