Discussion forum
CAD discussion |
Please abide by the rules of this forum.
How to post questions: register or login, go to the specific forum and click the NEW TOPIC button.
Rename Layout tab to Attribute |
Post Reply |
Author | |
SLING4
Newbie Joined: 19.May.2018 Location: Australia Using: AutoCAD2016 Status: Offline Points: 3 |
Topic: Rename Layout tab to Attribute Posted: 19.Aug.2019 at 02:31 |
Hi all
I'm new here. I have a modified LISP routine from V.Mich (which I love). It's working intermittently. I found that when I manually change the layout tab name to something random, then switch to model space and back to layout, the tab name updates. REGENALL also doesn't update the tab name. I use 3 attributes for the naming. i.e. _LOAattname "REV"; _LOAprefix "PREFIX"; _LOAsuffix "SUFFIX" This gives me a result e.g. [A] I'll really appreciate any comments! Routine: ;Change layout name dynamically by attribute value ;V.Michl - www.cadstudio.cz - www.cadforum.cz (setq _LOAblkname "AA_TITLEBLOCK") ; preset your title block name (setq _LOAattname "REV") ; preset your att. tag for the attribute carrying the requested layout name (setq _LOAprefix "PREFIX") ; sets prefix (setq _LOAsuffix "SUFFIX") ; sets suffix (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) ) ) ;---- (defun ssdynblk (effname / ssx c en blk) ;--------- *U modified dynblk (setq ssx (ssget "_X" (list (cons 0 "INSERT")(cons 2 "`*U*")(cons 410 lname)))) (setq c 0) (if ssx (repeat (sslength ssx) (setq en (vlax-ename->vla-object (ssname ssx c)) c (1+ c)) (if (= (strcase (vla-get-effectivename en)) (strcase effname)) (setq blk en) ) ) ) blk ) ;---- (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))) (setq blk (ssdynblk _LOAblkname)) ; dynblocks, slow... ) ; (if blk (setq property (vl-getattributevalue blk _LOAattname))) (if blk (setq property (strcat (vl-getattributevalue blk _LOAprefix) (vl-getattributevalue blk _LOAattname) (vl-getattributevalue blk _LOAsuffix)))) ; adds prefix & suffix property ) (defun _LOAchangedLayout (reactor layout / actl lname aname) ; single layout (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 _LOAprocess (reactor layout / ol actl lname aname) ; all layouts (setq ol (getvar "CTAB")); (car layout) ; act.layout (foreach lay (layoutlist) (setvar "CTAB" lay) (setq actl (vla-get-activelayout _LOAdoc)) (setq aname (_LOAgetAttVal lay)) ; get attribute (if (and aname (/= lay aname)) (progn (vla-put-name actl aname)(if (= ol lay)(setq ol aname))(princ " * LOA renamed * "))) ; rename (setvar "CTAB" ol) ) ) (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))))) ; and on any command (UNCOMMENT) ;(if(not #CommandEnded#) (setq #CommandEnded# (vlr-editor-reactor nil '((:vlr-endDwgOpen . _LOAprocess)(:vlr-beginSave . _LOAprocess)(:vlr-beginDxfOut . _LOAprocess))))) ; and on open/save (UNCOMMENT) (_LOAchangedLayout nil nil) (princ "\nNow ON") (princ) ) (princ "\nLOA reactor loaded.") (C:LOAon) (princ) |
|
Vladimir Michl
Moderator Group Arkance Systems CZ Joined: 26.Jul.2007 Location: Czech Republic Using: Autodesk software Status: Offline Points: 2015 |
Posted: 19.Aug.2019 at 06:34 |
Please make sure the block and attribute names in the routine match the names used in your title block.
And where is the problem? Your tab name updates? Its should update.
|
|
Vladimir Michl (moderator)
Arkance Systems - arkance-systems.cz - Autodesk reseller |
|
SLING4
Newbie Joined: 19.May.2018 Location: Australia Using: AutoCAD2016 Status: Offline Points: 3 |
Posted: 26.Aug.2019 at 07:11 |
Thanks for the replay!
Block names are correct and it does work. Problem is that it doesn't always update the layout tab when I change the attribute. When I open the file, it does update, but not while it's open. As mentioned: "It's working intermittently. I found that when I manually change the layout tab name to something random, then switch to model space and back to layout, the tab name updates. REGENALL also doesn't update the tab name."
|
|
Vladimir Michl
Moderator Group Arkance Systems CZ Joined: 26.Jul.2007 Location: Czech Republic Using: Autodesk software Status: Offline Points: 2015 |
Posted: 26.Aug.2019 at 07:44 |
So you are saying the switching back and forth does update the tab name - as it should. Where is the intermittency?
Does it behave like in the video?
|
|
Vladimir Michl (moderator)
Arkance Systems - arkance-systems.cz - Autodesk reseller |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |
This page was generated in 0,373 seconds.