Happy New Year to everyone!
I hope Christmas was a good one!
Using ACAD2002 (for now)
This routine finds any attribute within any and all titleblocks in our drawing files. It finds attributes with the tag "COPYRIGHT" OR "COPYRIGHTYEAR" and then updates the attribute value to read "2007 SNF CORPORATION".
at the beginning of each new year, this lisp routine is modified to reflect the new year. An easy task I admit. I was wondering if anyone knew of a way to modify this routine so we would not have to update this file every year.
All our existing drawings have to have the copyright year updated when they are opened for modification. We have this routine run automatically and it works great as is. Just trying to make everything a smidge better. Besides... I'm lazy.
;;; Updates copyright year attributes in all titleblocks
;;
(defun c:CRupdate (/ ss ent obj attributes att)
(vl-load-com)
(setq newtext "2007 SNF CORPORATION")
(setq ss (ssget "_X" '((0 . "INSERT"))))
(setq i -1)
(if ss
(while (setq ent (ssname ss (setq i (1+ i))))
(if (and (setq obj (vlax-ename->vla-object ent))
(= (vla-get-objectname obj) "AcDbBlockReference")
(= (vla-get-hasattributes obj) :vlax-true)
)
(progn
(setq attributes (vlax-invoke obj 'getattributes))
(foreach att attributes
(if (or (= "COPYRIGHT" (vla-get-tagstring att))
(= "COPYRIGHTYEAR" (vla-get-tagstring att))
)
(progn
(vla-put-textstring att newtext)
(vla-update att)
)
)
)
)
)
)
)
(or *doc* (setq *doc* (vla-get-activedocument (vlax-get-acad-object))))
(if (< 0 (vla-get-count (setq blks (vla-get-blocks *doc*))))
(progn
(vlax-for blk blks
(if (/= (vla-get-name blk) "*Model_Space")
(vlax-for ent blk
(if (and (vlax-property-available-p ent 'hasattributes)
(= (vla-get-hasattributes ent) :vlax-true)
)
(progn
(setq attributes (vlax-invoke ent 'getattributes))
(foreach att attributes
(if (or (= "COPYRIGHT" (vla-get-tagstring att))
(= "COPYRIGHTYEAR" (vla-get-tagstring att))
)
(progn
(vla-put-textstring att newtext)
)
)
)
)
)
)
)
)
(vla-regen *doc* acactiveviewport)
)
)
(princ)
)
(prompt "\nCopyright Update Loaded, Enter cupdate to run.")
(princ)
Thanks to SWAMP and all who have help me over the years!