- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all,
I need to rename tag name in block. Block name, old tag name and new tag name is known. I've found this code. It's working, but i want to specify actual block name in code, not by selection.
(defun C:C1 ( / oldtagname newtagname tagname ss x n blk att atts )
(vl-load-com)
(setq oldtagname "AUKSTIS")
(setq newtagname "ag")
(setq ss nill)
(prompt "\nPick All Blocks to Change: ")
(setq ss (ssget))
(if (and (/= oldtagname "")(/= newtagname "")(/= ss nil))
(progn
(setq x 0 n 0)
(repeat (sslength ss)
(setq blk (vlax-ename->vla-object (ssname ss x)))
(if (safearray-value (setq atts (vlax-variant-value (vla-getattributes blk))))
(progn
(setq atts (vlax-safearray->list (vlax-variant-value (vla-getattributes blk))))
(foreach att atts
(setq tagname (strcase (vla-get-tagstring att))); tagname
(if (and (/= newtagname "")(= tagname oldtagname))
(progn
(vla-put-tagstring att newtagname)
(setq n (+ n 1))
); progn
); if
); foreach
); progn
); if
(setq x (+ x 1))
); repeat length ss
(alert (strcat "Changed " (itoa n) " Tagnames to: " newtagname))
); progn
); if
(princ)
); function
Solved! Go to Solution.