Hello!
I have a drawing file with about 30 layouts, sheets of technical detail drawings.
Information of the template include date, name of designer, project no. etc.
the template is a block and can be edited by attribute definitions.
sometimes we have to change several information on the templates, how do i do this with all 30 layouts at once instead of editing it one by one?
what i have done so far is just creating a new dwt template file. load 30 layout files and paste the technical drawings into the new template file one by one - but this is very trivial and time consuming.
Solved! Go to Solution.
Solved by CodeDing. Go to Solution.
Instead of an attribute definition, you should be using a Field that points to a Custom Drawing Property.
DWGPROPS command dialog here:
https://help.autodesk.com/view/ACD/2025/ENU/?guid=GUID-8FCDDD74-0FDC-4189-8407-9EC9D7D482C5
Setup Custom Property fields here:
Best,
~DD
If you're using a new-enough version that the (getpropertyvalue)/(setpropertyvalue) approach is available, then Attribute Tags are "properties" of Block insertions, that you can assign values to. If you want to set the same new value into the same Tag in all insertions [such as the date?], you can do this, in simplest terms:
(if (setq ss (ssget "_X" '((2 . "YourBlockName"))))
(repeat (setq n (sslength ss)); then
(setpropertyvalue (ssname ss (setq n (1- n))) "YourTagName" "YourNewValue")
); repeat
); if
You can add more such (setpropertyvalue) functions within the same, if you have multiple same-value-in-all-insertions cases.
Like wise have a when starting a new project fill in all the common title block details to one layout it then copies all these details to the other 30 layouts. See attached.
To change certain attributes only across all layouts requires a different approach as you need somehow to select the attributes that only need changing. I have something that I can put together but it is limited to about 20 attributes due to screen limitations. Try this save multi getvals to a support directory or change Load to include full path.
; https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-bulk-edit-layout-template/td-p/12844209
; Change all title blocks based on new attribute values
; By Alan H June 2024
(defun wow ( / obj bname att atts lst ans ss blk x)
(setq obj (vlax-ename->vla-object (car (entsel "\nSelect title Block (attribute) "))))
(setq bname (vlax-get obj 'Name))
(setq atts (vlax-invoke obj 'Getattributes))
(setq lst '())
(foreach att atts
(setq lst (cons (vlax-get att 'Tagstring)lst))
(setq lst (cons 20 lst))
(setq lst (cons 19 lst))
(setq lst (cons "" lst))
)
(setq lst (reverse lst))
(setq lst (cons "Please change" lst))
(if (not AH:getvalsm)(load "Multi Getvals.lsp"))
(setq ans (AH:getvalsm lst))
(setq lays (layoutlist))
(foreach lay lays
(setvar 'ctab lay)
(command "Pspace")
(setq ss (ssget "X" (list (cons 0 "INSERT")(cons 2 bname)(cons 410 (getvar 'ctab)))))
(setq blk (vlax-ename->vla-object (ssname ss 0)))
(setq atts (vlax-invoke blk 'Getattributes))
(setq x 0)
(foreach val ans
(if (= val "")
(princ)
(vlax-put (nth x atts) 'Textstring val)
)
(setq x (1+ x))
)
)
(princ)
)
(wow)
The dcl will open all blank with tag names enter new values leave atts to not be changed as blank.
Hi CodeDing,
I am looking into these Fields
I have a few more questions though,
1) there are alot of fields including Project Number, Project name. How does AutoCAD know the Project Number and name? how do I insert these information in the first place?
2) regarding Sheet numberings
a) In my template I need to fill in the current sheet number (sheet#) and the total sheets of the drawing document (totalsheet#). the sheet# should be the current layout number and the totalsheet# should be the total number of layouts in the dwg file.
b) Additionally, i need to combine these drawing sheets with a PDF written file, so the sheet# should be :
sheet# = current layout number + 10, and totalsheet# = total layout number +10, how do i do that with the field?
c) I need to also fill in the 'parts' of the document. This is written in 3 digit numbers so e.g. 001, 007, 012 etc.
i understand that this probably uses the field mentioned in 2a) but i dont know how to make it a 3 digit format
3) I tried the fields 'CurrentSheetNumber', 'CurrentSheetDescription' etc. but they do not return a real value, only xxxx, #### and ----
i am not sure what went wrong here
t
okay,
i figured out 1, 2a and 2b and 3
i have even more questionts though,
i wanted to show only part of the file path, because the full file path is too long and unnecessary.
how do you do that in Fields?
Can't find what you're looking for? Ask the community or share your knowledge.