AutoCAD Electrical Forum
Welcome to Autodesk’s AutoCAD Electrical Forums. Share your knowledge, ask questions, and explore popular AutoCAD Electrical topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Change Attribute Name

2 REPLIES 2
Reply
Message 1 of 3
upscale
360 Views, 2 Replies

Change Attribute Name

I have a large number of drawings that have the wrong attribute tag name inside a title block. I would like to use the “Change Attribute Name” function in a script file so that the changes could be made, without having to call up every drawing and having to pick the block. Is there anyway to do this? I have searched the AutoLisp Programming in the reference guide, but I can’t find anything list for “Change Attribute Name”.
2 REPLIES 2
Message 2 of 3
Anonymous
in reply to: upscale

The "Change Attribute Name" is a utility built into AcadE and issues a couple command line prompts. It won't work in a script file. Below is a little utility that you should be able to pop into a script file and then use with AcadE's "Project-Wide Utilities" command. Cut and paste the program below into a file called attr_rename.lsp. Then APPLOAD this utility. Create a one-line AutoCAD script file with one line in it: (c:attr_rename ) it might look like this: (c:attr_rename "D-SIZE" "DRAWN_BY" "CREATED_BY") Then run the Project-Wide Utilities and reference this script. Give this a shot and see if it works. It may or may not. Nate. (defun c:attr_rename ( blockname oldattrnam newattrnam / x_en enn edd ss slen ) ; Search for first or only instance of "blockname" in the current drawing (setq ss (ssget "_X" (list (cons -4 "")))) (if (/= ss nil) (progn (setq tb_ent (ssname ss 0)) ; assume first or only instance is the title block ; Now search for target attribute on this title block (setq enn (entnext tb_ent)) (setq edd (entget enn)) (setq hit nil) (while (AND (not hit) enn (/= (cdr (assoc 0 edd)) "SEQEND") (/= (cdr (assoc 0 edd)) "INSERT") ) (if (= (cdr (assoc 0 edd)) "ATTRIB") (progn (setq atnam (cdr (assoc 2 edd))) (if (OR (= atnam oldattrnam) (wcmatch atnam oldattrnam)) (progn ; found it! ; Change name now (setq newed (subst (cons 2 newattrnam) (assoc 2 edd) edd)) ; substitute new name (entmod newed) ; update the title block instance (entupd tb_ent) (princ "\n") (princ oldattrnam) (princ " --> ") (princ newattrnam) (setq hit 1) ; flag to exit this loop ) ) ) ) ; go to next sub ent in block instance and loop back up (if (setq enn (entnext enn)) (setq edd (entget enn))) ) (setq ss nil) ; release the selection set ) ) (princ) ; prettier ) "upscale" wrote in message news:24549422.1076032506958.JavaMail.jive@jiveforum1.autodesk.com... I have a large number of drawings that have the wrong attribute tag name inside a title block. I would like to use the "Change Attribute Name" function in a script file so that the changes could be made, without having to call up every drawing and having to pick the block. Is there anyway to do this? I have searched the AutoLisp Programming in the reference guide, but I can't find anything list for "Change Attribute Name".
Message 3 of 3
upscale
in reply to: upscale

Nate, you are the MAN! This worked just like I wanted it to. Thanks again

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost