Results 1 to 8 of 8

Thread: Rename Layout Tabs

  1. #1
    100 Club
    Join Date
    2007-02
    Location
    Porto
    Posts
    107
    Login to Give a bone
    0

    Default Rename Layout Tabs

    Hi,
    I use this peace of code to rename layout names, but it would be nice if i could rename all layout tabs. Is it possible?
    Code:
    (defun c:renomeartabs ( / doc layouts)
    (vl-load-com) 
    (setq layouts (vla-get-Layouts (vla-get-ActiveDocument (vlax-get-acad-object))))
    (vlax-for layout layouts
    (while (vl-string-search "01A" (vla-get-name layout))
    (vla-put-name layout (vl-string-subst "01B" "01A" (vla-get-name layout)))))
    (princ)
    )
    I have layouts with that sequence: 01A, 02A, 03A, 04A and so on...and i try to rename all to 01B, 02B, 03B, 04B, and so on...

    Thank you.

  2. #2
    100 Club
    Join Date
    2007-02
    Location
    Porto
    Posts
    107
    Login to Give a bone
    0

    Default Re: Rename Layout Tabs

    Ok.
    I made a small change and i can change from A to B but do not know how the programming with dialog boxes can not adjust to what I intend. The idea was I could choose to change for example from A to C. Any help or indication? Thanks
    Code:
    (defun c:tabren ( / doc layouts)
    (vl-load-com)
    (setq layouts (vla-get-Layouts (vla-get-ActiveDocument (vlax-get-acad-object))))
    (vlax-for layout layouts
    (while (vl-string-search "A" (vla-get-name layout))
    (vla-put-name layout (vl-string-subst "B" "A" (vla-get-name layout)))))
    (princ)
    )
    Last edited by pt_zooropa; 2009-09-01 at 03:05 PM. Reason: Code

  3. #3
    The Silent Type RobertB's Avatar
    Join Date
    2000-01
    Location
    Seattle WA USA
    Posts
    5,859
    Login to Give a bone
    0

    Default Re: Rename Layout Tabs

    Why attempt to use dialog boxes? That is overkill for this application. Simply ask the user to provide the old string to replace with the new string, e.g.:
    Code:
    (setq inpOld (getstring "\nOriginal text to replace: "))
    (setq inpNew (getstring "\nNew text with which to replace: "))
    R. Robert Bell
    Design Technology Manager
    Stantec
    Opinions expressed are mine alone and do not reflect the views of Stantec.

  4. #4
    100 Club
    Join Date
    2007-02
    Location
    Porto
    Posts
    107
    Login to Give a bone
    0

    Default Re: Rename Layout Tabs

    Thanks for the tip. But as I attach the new string to all the names of the layout? Sorry my poor english.

  5. #5
    The Silent Type RobertB's Avatar
    Join Date
    2000-01
    Location
    Seattle WA USA
    Posts
    5,859
    Login to Give a bone
    0

    Lightbulb Re: Rename Layout Tabs

    Quote Originally Posted by pt_zooropa View Post
    Thanks for the tip. But as I attach the new string to all the names of the layout?
    Code:
    (defun c:tabren ( / doc layouts)
     (vl-load-com)
     (cond ((and (/= (setq inpOld (getstring "\nOriginal text to replace: ")) "")
                 (/= (setq inpNew (getstring "\nNew text with which to replace: ")) ""))
            (setq doc (vla-get-ActiveDocument (vlax-get-acad-object)))
            (setq layouts (vla-get-Layouts doc))
            (vlax-for layout layouts
            (while (vl-string-search inpOld (vla-get-name layout))
             (vla-put-name layout (vl-string-subst inpNew inpOld (vla-get-name layout)))))))
     (princ))
    Quote Originally Posted by pt_zooropa View Post
    Sorry my poor english.
    Your English is better than my Portuguese.
    R. Robert Bell
    Design Technology Manager
    Stantec
    Opinions expressed are mine alone and do not reflect the views of Stantec.

  6. #6
    100 Club
    Join Date
    2007-02
    Location
    Porto
    Posts
    107
    Login to Give a bone
    0

    Default Re: Rename Layout Tabs

    Your English is better than my Portuguese.
    Is that so? lol
    Thank you for the help! Done!

  7. #7
    Member
    Join Date
    2009-02
    Posts
    4
    Login to Give a bone
    0

    Default Re: Rename Layout Tabs

    Quote Originally Posted by RobertB View Post
    Code:
    (defun c:tabren ( / doc layouts)
     (vl-load-com)
     (cond ((and (/= (setq inpOld (getstring "\nOriginal text to replace: ")) "")
                 (/= (setq inpNew (getstring "\nNew text with which to replace: ")) ""))
            (setq doc (vla-get-ActiveDocument (vlax-get-acad-object)))
            (setq layouts (vla-get-Layouts doc))
            (vlax-for layout layouts
            (while (vl-string-search inpOld (vla-get-name layout))
             (vla-put-name layout (vl-string-subst inpNew inpOld (vla-get-name layout)))))))
     (princ))

    Your English is better than my Portuguese.
    Thanks RobertB. This code (6 years on ) has saved me much time today in not having to manually rename may tabs.

  8. #8
    Member
    Join Date
    2012-10
    Posts
    3
    Login to Give a bone
    0

    Default Re: Rename Layout Tabs

    Hi, paulof and RobertB, thanks!! for sharing your code, I used it with reactors and it works very well!!

Similar Threads

  1. Batch Rename Tool for Layout Tabs?
    By WhataMaroon in forum AutoCAD Customization
    Replies: 3
    Last Post: 2016-11-06, 03:01 AM
  2. Layout tabs names change when layout renamed in SSM
    By autocad.wishlist1734 in forum AutoCAD Wish List
    Replies: 2
    Last Post: 2013-01-20, 05:07 AM
  3. Rename a layout tab
    By dfuehrer in forum AutoLISP
    Replies: 6
    Last Post: 2008-05-14, 06:36 AM
  4. Rename Layout tabs on multiple .dwg
    By Dave Lewis in forum AutoCAD General
    Replies: 3
    Last Post: 2008-03-19, 07:40 PM
  5. Publish layout tabs and layout tab names to PDF
    By dfuehrer in forum AutoCAD Plotting
    Replies: 9
    Last Post: 2005-11-09, 02:49 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •