Change multiple block attribute values in one click

Change multiple block attribute values in one click

toolbox2
Advocate Advocate
9,144 Views
10 Replies
Message 1 of 11

Change multiple block attribute values in one click

toolbox2
Advocate
Advocate

I have a lot of drawings, each with one or more title blocks with attributes. I need to update the attribute values with some predefined values. The same values will be used in whichever title block I select within the drawing. The title blocks are dynamic blocks.

 

Since the attribute and values will always be the same I thought I could customise a button to make this a one-click job for each title block that I select. Initially, I thought this could be accomplished with Lisp but then thought there must surely be an AutoCAD command I could use for this. But...I haven't found it.

 

The Express Tools command ATTIN looked hopeful. Put the tags and values in a text file and run the command. But how to execute this in one click? Need to pass the text file location and select the block without dialogue boxes.

 

I'm just not sure which way to go with this. Standard AutoCAD commands or Lisp. I'm unable to use scripts since  SCR files are prohibited on our locked down machines.

 

Any help would be gratefully received.

0 Likes
9,145 Views
10 Replies
Replies (10)
Message 2 of 11

vinodkl
Mentor
Mentor

Hi @toolbox2 

 

Have you tried the command "GATTE" (Global ATTribute Editor)? Using this command you can set a new value of the attribute globally inside the drawing 🙂

--------------------------------------------------------------------------------------------------------------------------
ವಿನೋದ್ ಕೆ ಎಲ್( System Design Engineer)
Likes is much appreciated if the information I have shared is helpful to you and/or others.

Please mark "Accept as Solution" if my reply resolves the issue or answers your question, to help others in the community.
--------------------------------------------------------------------------------------------------------------------------
0 Likes
Message 3 of 11

toolbox2
Advocate
Advocate

GATTE doesn't work with Dynamic Blocks, unfortunately.

 

0 Likes
Message 4 of 11

murray-clack
Advisor
Advisor

If you are looking for "one click" solutions to change global title-block info (i.e. project name, client name, project number, etc.) then using the Sheet Set Manager is your best bet.

0 Likes
Message 5 of 11

toolbox2
Advocate
Advocate

It would, wouldn't it? But not for this task facing me now.

0 Likes
Message 6 of 11

JTBWorld
Advisor
Advisor

Maybe our attribute editor app JTB BatchAttEdit can help. 


Jimmy Bergmark
JTB World - Software development and consulting for CAD and license usage reports
https://jtbworld.com

0 Likes
Message 7 of 11

RobDraw
Mentor
Mentor

I would use an XREF for identical information shared across multiple files.


Rob

Drafting is a breeze and Revit doesn't always work the way you think it should.
0 Likes
Message 8 of 11

maratovich
Advisor
Advisor

 

Try using this - AutoReplaceCAD 

 

 

---------------------------------------------------------------------
Software development
Automatic creation layouts and viewport. Batch printing drawings from model.
www.kdmsoft.net
0 Likes
Message 9 of 11

toolbox2
Advocate
Advocate

Thanks but the attribute values won't necessarily change for EVERY instance of a block, only the ones I select.

 

It's looking like an AutoCAD command solution isn't out there.

 

I found a modified GATTE command, GATTE2, on CadTutor.net. With some modification this looks hopeful.

0 Likes
Message 10 of 11

RobDraw
Mentor
Mentor

As much as some people think, AutoCAD cannot read minds. Any one click solution would require an amount of coding that might take much longer to write and troubleshoot than it would be to do the task manually.


Rob

Drafting is a breeze and Revit doesn't always work the way you think it should.
Message 11 of 11

Bertrandick
Observer
Observer

Here is the my lisp for multiple attribute changer that ChatGPT made.

1. Save it to XXX.lsp in Notepad

 

;; ------------------------------------------------------------
;; ATTBATCH — Batch-edit Attribute values on selected INSERTs
;; ------------------------------------------------------------
;; What it does
;; Updates Attribute VALUE (DXF code 1) for the chosen TAG on
;; every selected block reference (entity type: INSERT).
;;
;; Command
;; ATTBATCH
;;
;; Usage
;; 1) Load with APPLOAD.
;; 2) Type ATTBATCH.
;; 3) Enter the Attribute TAG to change.
;; - Type "*" (just an asterisk) to update ALL tags.
;; - Otherwise only the matching TAG (case-insensitive) is changed.
;; 4) Enter the NEW value to apply.
;; 5) Select target block references (INSERT). Press Enter to finish.
;;
;; Notes
;; - Constant Attributes (from ATTDEF set to Constant) aren’t present
;; on instances; edit the block definition and then run ATTSYNC for those.
;; - If an Attribute had a Field, it will be replaced by plain text.
;; - Works with MINSERT: each instance is processed.
;; - Pure AutoLISP only: compatible with environments lacking VLA/ActiveX.
;;
;; Change log
;; - Only treats "*" as “all tags”. A real TAG string updates that TAG only.
;; ------------------------------------------------------------

(defun c:ATTBATCH (/ _equal-ci _collect-attribs
tag new ss i ent cnt
lst a dxf atag doAll)

;; Case-insensitive compare
(defun _equal-ci (s1 s2) (= (strcase s1) (strcase s2)))

;; Collect ATTRIB entities following an INSERT until SEQEND
(defun _collect-attribs (ins / e typ acc)
(setq e (entnext ins))
(while (and e
(setq typ (cdr (assoc 0 (entget e))))
(/= typ "SEQEND"))
(if (= typ "ATTRIB") (setq acc (cons e acc)))
(setq e (entnext e))
)
(reverse acc)
)

;; Inputs
(setq tag (getstring T "\nEnter Attribute TAG to change (* = all): "))
(if (null tag) (setq tag ""))
(setq new (getstring T "\nEnter new Attribute value: "))
(if (null new) (setq new ""))

;; ONLY treat as 'all' when the user typed "*" exactly
(setq doAll (= (strcase tag) "*"))

(prompt "\nSelect block references (INSERT): ")
(setq ss (ssget '((0 . "INSERT"))))

(if ss
(progn
;; optional: group into one undo step (pure command call)
(command "_.UNDO" "_Begin")

(setq cnt 0
i 0)
(while (< i (sslength ss))
(setq ent (ssname ss i))
(setq lst (_collect-attribs ent))

;; Process each ATTRIB
(while lst
(setq a (car lst)
dxf (entget a)
;; TAG = code 2, VALUE = code 1
atag (cdr (assoc 2 dxf)))
(if (or doAll
(_equal-ci atag tag))
(progn
;; Update value (code 1); add if missing
(if (assoc 1 dxf)
(setq dxf (subst (cons 1 new) (assoc 1 dxf) dxf))
(setq dxf (append dxf (list (cons 1 new))))
)
(entmod dxf)
(setq cnt (1+ cnt))
)
)
(setq lst (cdr lst))
)
;; Refresh display for the block reference
(entupd ent)
(setq i (1+ i))
)

(command "_.UNDO" "_End")
(princ (strcat "\nDone: updated " (itoa cnt) " Attribute(s)."))
)
(prompt "\nSelection canceled.")
)
(princ)
)

0 Likes