Here is my old one, it works good for me in A2005, try it
Code:
;;=============================================================;
;; *| DBX-CHANGE-ATT.lsp | Fatty The Old Horse © 2004 All rights removed |* ;
;;=============================================================;
;; edited 4/20/06
;; edited 5/28/06
(defun odbx-test (/ dbx_doc)
(if (< (atof (getvar "ACADVER")) 15.06)
(progn (alert "ObjectDBX method not applicable\nin this AutoCAD version")
(exit)(princ)(gc))
(progn
(if (= (atoi (getvar "ACADVER")) 15)
(progn
(if (not (vl-registry-read
"HKEY_CLASSES_ROOT\\ObjectDBX.AxDbDocument\\CLSID"))
(startapp "regsvr32.exe"
(strcat "/s \"" (findfile "axdb15.dll") "\"")))
(setq dbx_doc (vla-getinterfaceobject
(vlax-get-acad-object)
"ObjectDBX.AxDbDocument")))
(setq dbx_doc (vla-getinterfaceobject
(vlax-get-acad-object)
"ObjectDBX.AxDbDocument.16"))))))
; ;
(defun put-new-value (actdoc blk_name cur_tag new_value / actspace att_obj_list)
(vlax-for b (vla-get-modelspace actdoc)
(if (and
(eq (vla-get-objectname b) "AcDbBlockReference")
(vlax-read-enabled-p b)
(vlax-write-enabled-p b)
(vlax-method-applicable-p b 'Getattributes)
(eq (strcase (vla-get-name b)) (strcase blk_name))
)
(progn
(setq att_obj_list (vlax-invoke b 'Getattributes))
(foreach at att_obj_list
(if (eq cur_tag (strcase (vlax-get at 'Tagstring )))
(progn
(vlax-put at 'Textstring new_value)
(vla-update at)))))))
(gc)
(princ)
)
;;__________________MAIN PART___________________;;
(defun C:chat (/ acapp adoc blk_name cur_tag fn fname
fold full_name_list mdmod new_value
other_doc)
(vl-load-com)
(or acapp (setq acapp (vlax-get-acad-object)))
(or adoc (setq adoc (vla-get-activedocument acapp)))
(vla-endundomark adoc)
(vla-startundomark adoc)
(setq mdmod (vla-getvariable adoc "SDI"))
(vla-setvariable adoc "SDI" (vlax-make-variant 1 vlax-vbinteger))
(setq blk_name "mytitle";(getstring T "\nBlock name (case sensitive):\n")
cur_tag "TITLE_1";(getstring "\nAttribute tag to be change:\n")
new_value " >>> HAS CHANGED MY FIRST LINE OF THE TITLE BLOCK?");(getstring T "\nNew value of an attribute:\n"))
(setq fn (getfiled "Select ANY .DWG FILE in a desired folder : "
""
"dwg"
4
)
fold (vl-filename-directory fn)
full_name_list (vl-directory-files fold "*.dwg" 1)
full_name_list (mapcar (function (lambda (x)
(strcat fold "\\" x)
)
)
full_name_list
)
)
(foreach other full_name_list
(if
(setq fname (findfile other))
(progn
(setq other_doc (odbx-test))
(vla-open other_doc fname)
(put-new-value other_doc blk_name cur_tag new_value)
(vlax-invoke other_doc 'SaveAs fname)
(vl-catch-all-apply (function (lambda ()
(vla-release-object other_doc))))
(setq other_doc nil)
(vl-catch-all-apply (function (lambda ()
(vla-update acapp))))
)
(princ "\File Not Found")
)
)
(vla-setvariable adoc "SDI" mdmod)
(vla-endundomark adoc)
(gc)
(princ)
)
(prompt "\n===========================\n")
(prompt "\n Type CHAT to execute ... ")
(prompt "\n===========================\n")
(princ)
f.