CAD Forum - tips, tricks, discussion and utilities for AutoCAD, Inventor, Revit and other Autodesk products []
Cesky English Deutsch
 Visitors: 4870 

CAD tip CAD tip # 11780:

Question CAD 
 %  platform  category 
Q - question

How to rename layouts by a specific attribute of the title block?

A - answer With the following LISP reactor - RenameLOA - you can make the layout tab name match an attribute in the title block (frame). The RenameLOA.lsp freeware utility can be downloaded from

Just set the two parameters - block- and attribute-name of your title block in the LISP file and load it with APPLOAD (drag to the briefcase icon) to every AutoCAD session. You can also optionally comment out the CommandEnded reactor and so check the attribute only on a layout switch. Use the LOAon and LOAoff commands to switch reactor(s) ON and OFF.

See example of the setting:

(setq _LOAblkname "TitleBlock") ; preset your title block name
(setq _LOAattname "LayoutName") ; preset your att. tag for the attribute
                                ; carrying the requested layout name

The layout is then automatically renamed to the current value of the specified attribute in the title block (if any) inserted in the respective layout.

See sample video:

Updated version on

Source code:

;Change layout name dynamically by attribute value
;V.Michl - -

(setq _LOAblkname "TitleBlock") ; preset your title block name
(setq _LOAattname "LayoutName") ; preset your att. tag for the attribute carrying the requested layout name


(setq _LOAdoc (vla-get-activedocument (vlax-get-acad-object)))

(defun _LOAgetAttVal (lname / ss blk property)
 (defun vl-getattributevalue ( blk tag )
    (setq tag (strcase tag))
    (vl-some '(lambda ( att ) (if (= tag (strcase (vla-get-tagstring att))) (vla-get-textstring att)))
        (vlax-invoke blk 'getattributes)
 (setq ss (ssget "_X" (list (cons 0 "INSERT")(cons 2 _LOAblkname)(cons 410 lname))))
 (if ss (setq blk (vlax-ename->vla-object (ssname ss 0))))
 (if blk (setq property (vl-getattributevalue blk _LOAattname)))

(defun _LOAchangedLayout (reactor layout / actl lname aname)
 (setq lname (getvar "CTAB")); (car layout) ; act.layout
 (setq actl (vla-get-activelayout _LOAdoc)) ; vla-get-name
 (if (/= lname "Model")(progn
  (setq aname (_LOAgetAttVal lname)) ; get attribute
  (if (and aname (/= lname aname)) (progn (vla-put-name actl aname)(princ " * LOA renamed * "))) ; rename

(defun C:LOAoff ( )
 (if #LayoutSwitcher# (progn (vlr-remove #LayoutSwitcher#)(setq #LayoutSwitcher# nil)))
 (if #CommandEnded# (progn (vlr-remove #CommandEnded#)(setq #CommandEnded# nil)))
 (princ "\nNow OFF")
(defun C:LOAon ( )
 (if(not #LayoutSwitcher#) (setq #LayoutSwitcher# (VLR-Miscellaneous-Reactor nil '((:VLR-layoutSwitched . _LOAchangedLayout))))) ; on layout change
 (if(not #CommandEnded#) (setq #CommandEnded# (VLR-Command-Reactor nil '((:VLR-commandEnded . _LOAchangedLayout))))) ; also on any command
 (_LOAchangedLayout nil nil)
 (princ "\nNow ON")

(princ "\nLOA reactor loaded.")

Since June 2018, the reactor also supports dynamic blocks.

100% *  CAD 
31.1.2018    2150×  
Comments   Tell a friend
applies to: AutoCAD ·

See also:
Tip 11821:How to publish PDF sheets (pages) under the plain layout name?
Tip 11542:How to reset the top browser node name back to the file name?
Tip 11171:Total number of layouts as a field.
Tip 10759:How to publish a DWG to a PDF file without attaching "-Model" to its name?
Tip 9870:Xref NAME has multiple references. Not detached.

Back   All CAD Tips All CAD tips&tricks

Invalid number or bad continuation - when creating a linetype. « | » Export XYZ coordinates of DWG objects from AutoCAD LT.

Have we helped you? If you want to support the CAD Forum web service, consider buying one of our CAD applications, or our custom software development offerings, or donating via PayPal (see above). You may also add a link to your web - like this "fan" link: CAD Forum - tips, utilities, blocks for Autodesk products
CAD:    OS:    Categ: 
Text:  FAQ glossary   

DwgTextTranslator translates a series of drawings from one language to another using MS Access.
Download a fully functional trial version.

Please use these tips at your own risk.
CAD Studio (Xanadu) is not responsible for possible problems that may occur as a result of using any of these tips.