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 Download.
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, or you can run the renaming process only on open/save (the 3rd reactor). 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 Download
Source code:
;Change layout name dynamically by attribute value
;V.Michl - www.cadstudio.cz - www.cadforum.cz
(setq _LOAblkname "TitleBlock") ; preset your title block name
(setq _LOAattname "LayoutName") ; preset your att. tag for the attribute carrying the requested layout name
(vl-load-com)
(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)))
property
)
(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")
(princ)
)
(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)
)
(princ "\nLOA reactor loaded.")
(C:LOAon)
(princ)
Since June 2018, the reactor also supports dynamic blocks.
Download the latest version from Download which includes also an optional onOpen/onSave reactor (instead of onAnyCommand).