Originally Posted by
rkingery
Does anyone know of a way, or have a routine, that will edit the tag name (not the value) of an attribute in an existing block? I'm aware of BATTMAN's capability here but I have a HUGE number of drawings that require some tag renaming and I'm hoping to create a script to run overnight.
Thanks,
Randy
Randy,
Give this a try:
Code:
(defun MKSxAttTagSet
(obj ;;variable - object to use
att ;;variable - attribute to set
str ;;variable - new tag name
/
atts ;;variable - list of attributes
bool ;;variable - returns t if set, returns nil if not
index ;;variable - index/counter
)
(setq atts (vlax-safeArray->list (variant-value (vla-getAttributes obj)))
index 0
)
(repeat (length atts)
(if (= (vla-get-tagString (nth index atts)) att)
(progn
(vla-put-tagString (nth index atts) str)
(vla-update (nth index atts))
(setq bool t)
)
)
(setq index (1+ index))
)
bool
)
You would call it like this:
Code:
(MKSxAttTagSet objBlk TagOld TagNew)
This routine will update ALL attribute tags with the old name (TagOld). If nothing it updated, nil is returned; otherwise t is returned.