Author Topic: rename layout tabs??  (Read 14586 times)

0 Members and 1 Guest are viewing this topic.

pmvliet

  • Guest
rename layout tabs??
« on: June 01, 2004, 12:11:56 PM »
I have some clients and some users that like renaming layout1 to be the sheet number. ie: instead of layout1 they name it to A-101, A-102, E-101 etc. Each layout is in it's own file. So there is a model tab and say A-101 tab.

Is there a way to rename them globally back to layout1? Does anyone have something already written? I have come up with two options. a way to rename the tab or a way to thaw/unlock all layers, block out the paperspace items, delete the layout and AutoCad will automatically re-create layout1 and then insert the blocked items and return the layers to their previous state...

Any ideas/bits of code.

Thanks,
pieter

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
rename layout tabs??
« Reply #1 on: June 01, 2004, 12:58:16 PM »
Code: [Select]

(defun c:re-name-layout (/ layoutsObj)
(vl-load-com)

(setq layoutsObj
  (vlax-get-property
(vla-get-ActiveDocument
  (vlax-get-acad-object)
  )
'Layouts
)
 )

(vlax-put-property
 (vla-item layoutsObj 1)
 'Name "Layout1"
 )

)
TheSwamp.org  (serving the CAD community since 2003)

pmvliet

  • Guest
rename layout tabs??
« Reply #2 on: June 01, 2004, 01:12:13 PM »
Hi Mark,

for some reason when i try to run this it say's "; error: Automation Error. Cannot rename the Model layout"

Is it looking for A-101 or A101 or does it really matter?

Thanks,
Pieter

hendie

  • Guest
rename layout tabs??
« Reply #3 on: June 01, 2004, 01:19:40 PM »
as far as I'm aware, you cannot rename or delete the model tab

Jeff_M

  • King Gator
  • Posts: 4094
  • C3D user & customizer
rename layout tabs??
« Reply #4 on: June 01, 2004, 01:22:57 PM »
Give this a try:
Code: [Select]

(defun c:name->layout1 ()
  (if (or (and (member "Model" (layoutlist))
      (= 2 (length (layoutlist)))
      )
 (= 1 (length (layoutlist)))
 )
    (progn
      (vlax-for x (vla-get-layouts
   (vla-get-activedocument
     (vlax-get-acad-object)))
(if (not (= (vla-get-name x) "Model"))
 (vla-put-name x "Layout1")
 )
)
      )
    )
  (princ)
  )

Jeff

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
rename layout tabs??
« Reply #5 on: June 01, 2004, 01:33:06 PM »
Nope cannot rename or move a model tab....

Try this VBA macro, it will rename all layout tabs to LayoutX where X is the indexed order...

Code: [Select]

Sub RNLayout()
Dim ACLayout As AcadLayout
Dim ACLayouts As AcadLayouts
Set ACLayouts = ThisDrawing.Layouts
 For Each ACLayout In ACLayouts
  If ACLayout.Name <> "Model" Then
   ACLayout.Name = "Layout" & ACLayout.TabOrder
  End If
 Next
End Sub


If this is combined with my BrowseForFolder macro, you will be able to open a specific folder, open each drawing, change each one, save and close each one, all without user intervention.

To do so will require a little bit more code, but it is possible....
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

pmvliet

  • Guest
rename layout tabs??
« Reply #6 on: June 01, 2004, 03:59:06 PM »
I am not trying to rename the model tab. I am trying to rename a layout tab that has been renamed to something other then layout1.

Jeff, I'll try yours in the morning and keith I'll need to get some help on the VBA macro...

I gotta run so thanks for the help and I'll be back on Wednesday.

pieter

sestes

  • Guest
Rename layout to layout1
« Reply #7 on: June 16, 2004, 01:25:37 PM »
Quote from: Mark Thomas
Code: [Select]

(defun c:re-name-layout (/ layoutsObj)
(vl-load-com)

(setq layoutsObj
  (vlax-get-property
(vla-get-ActiveDocument
  (vlax-get-acad-object)
  )
'Layouts
)
 )

(vlax-put-property
 (vla-item layoutsObj 1)


 'Name "Layout1"
 )

)
I'm not sure if pmvliet had any sucess, but I accually had to use this today for about 700+ drawings and it worked great.  Glad I keep up with the post's or I would have had a tough time.

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Re: Rename layout to layout1
« Reply #8 on: June 16, 2004, 02:23:30 PM »
Quote from: sestes
I'm not sure if pmvliet had any sucess, but I accually had to use this today for about 700+ drawings and it worked great.  Glad I keep up with the post's or I would have had a tough time.

Excellent !!

<funny mode>
now about my bill, where should I send it again?
</funny mode>
TheSwamp.org  (serving the CAD community since 2003)

Slim©

  • Needs a day job
  • Posts: 6566
  • The Dude Abides...
Re: Rename layout to layout1
« Reply #9 on: June 16, 2004, 02:34:31 PM »
Quote from: Mark Thomas
<funny mode>
now about my bill, where should I send it again?
</funny mode>


Didn't you turn down payment HERE?
I drink beer and I know things....

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
rename layout tabs??
« Reply #10 on: June 16, 2004, 08:49:36 PM »
It's a little late, but how about this one I cooked up.
Code: [Select]
;; This routine will rename all layout tabs in all open drawings
;;  to "Layoutx" where x = the tab count
(defun c:re-name-all-layouts (/ Tab_name doc x cnt)
  (vl-load-com)
  (setq Tab_name "Layout")
  (vlax-for doc (vla-get-documents (vlax-get-acad-object))
    (setq cnt 0)
    (vlax-for x (vla-get-layouts doc)
      (if (not (= (vla-get-name x) "Model"))
        (vla-put-name x
          (strcat Tab_name (itoa (setq cnt (1+ cnt))))
        )
      )
    )
  )
)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

One Shot

  • Guest
rename layout tabs??
« Reply #11 on: October 01, 2004, 03:08:48 PM »
cCan this routine be changed to allow  would like to see if Tabs could go Tab 1, Tab 2, Tab 3 or Tab A, Tab B, Tab C and so on. Can it also use anything that you want?

ELOQUINTET

  • Guest
rename layout tabs??
« Reply #12 on: October 01, 2004, 03:18:06 PM »
(setq Tab_name "Layout")

i'd imagine you could just change layout in this line to tab. as far as changing it to alpha instead of numeric not sure which way to point you but i'm sure it could be done. these guys can help you i'm sure

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
rename layout tabs??
« Reply #13 on: October 01, 2004, 03:36:49 PM »
This VBA one can do Tab 1 Tab 2 ..... all you need to do is change "Layout" to "Tab "...
Code: [Select]
Sub RNLayout()
Dim ACLayout As AcadLayout
Dim ACLayouts As AcadLayouts
Set ACLayouts = ThisDrawing.Layouts
 For Each ACLayout In ACLayouts
  If ACLayout.Name <> "Model" Then
   ACLayout.Name = "Layout" & ACLayout.TabOrder
  End If
 Next
End Sub


To do Tab A, Tab B, Tab C ..... you will need to include a minor change to make it happen...

Code: [Select]
Sub RNLayout()
Dim ACLayout As AcadLayout
Dim ACLayouts As AcadLayouts
Set ACLayouts = ThisDrawing.Layouts
 For Each ACLayout In ACLayouts
  If ACLayout.Name <> "Model" Then
   ACLayout.Name = "Layout" & Chr(ACLayout.TabOrder + 64)
  End If
 Next
End Sub


If you have over 26 layouts, you will get wierd names though .... and will crash if more than 255 tabs
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
rename layout tabs??
« Reply #14 on: October 01, 2004, 04:51:28 PM »
Keith, man you are fast... 8)

Here is a lisp version.
Code: [Select]
;;; FUNCTION
;;;  This routine will rename all layout tabs with
;;;   user entered prefix & number or letter suffix
;;;
;;; ARGUMENTS
;;; none
;;;
;;; USAGE
;;;  re-name-layouts
;;;
;;; PLATFORMS
;;;  2000+
;;;
;;; AUTHOR
;;; Copyright© 2004 Charles Alan Butler
;;; ab2draft@TampaBay.rr.com
;;;
;;; VERSION
;;;  1.0 Oct. 01, 2004
;;;
;;;  This software is provided "as is" without express or implied      ;
;;;  warranty.  All implied warranties of fitness for any particular   ;
;;;  purpose and of merchantability are hereby disclaimed.             ;
;;;  You are hereby granted permission to use, copy and modify this    ;
;;;  software without charge, provided you do so exclusively for       ;
;;;  your own use or for use by others in your organization in the     ;
;;;  performance of their normal duties, and provided further that     ;
;;;  the above copyright notice appears in all copies and both that    ;
;;;  copyright notice and the limited warranty and restricted rights   ;
;;;  notice appear in all supporting documentation.                    ;
;;;
(defun c:re-name-layouts (/ tab_name doc cnt x suffix new_list)
  (vl-load-com)
  (setq tab_name (getstring t "\nEnter Tab Name prefix (add trailing space): "))
  (cond (tab_name) ((setq tab_name "")))
  (initget "Numbers Letters")
  (setq suffix (getkword "\nSuffix to use? [Numbers or Letters] : <Numbers> "))
  (cond (suffix) ((setq suffix "Numbers")))
  (setq *doc* (vla-get-activedocument (vlax-get-acad-object)))

  (vlax-for tab (vla-get-layouts ; get list of layout tabs
                  (vla-get-activedocument (vlax-get-acad-object)))
    (if (/= (setq tmpname (vla-get-name tab)) "Model") ; omit MODEL space
      (setq new_list (cons (cons (vla-get-taborder tab) tab) new_list))
    )
  )
  ;;  sort list acording to tab order
  (setq new_list (vl-sort new_list
                  '(lambda (e1 e2) (< (car e1) (car e2)))))
  ;;remove the taborder numbers
  (setq new_list (mapcar 'cdr new_list))

  ;; rename the tabs
  (setq cnt (cond ((= suffix "Numbers") 0) (64)))
  (foreach x new_list
    (vla-put-name x
       (strcat tab_name
               (cond
                 ((= suffix "Numbers")
                   (itoa (setq cnt (1+ cnt))))
                 ((chr (setq cnt (1+ cnt))))
               )))
  )
  (princ)
) ; defun
(prompt "\n*-*  Rename Tab layouts Loaded, Enter re-name-layouts to run. *-*")
(princ)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

One Shot

  • Guest
rename layout tabs??
« Reply #15 on: October 01, 2004, 05:16:45 PM »
Quote from: CAB
Keith, man you are fast... 8)

Here is a lisp version.
Code: [Select]
;;; FUNCTION
;;;  This routine will rename all layout tabs with
;;;   user entered prefix & number or letter suffix
;;;
;;; ARGUMENTS
;;; none
;;;
;;; USAGE
;;;  re-name-layouts
;;;
;;; PLATFORMS
;;;  2000+
;;;
;;; AUTHOR
;;; Copyright© 2004 Charles Alan Butler
;;; ab2draft@TampaBay.rr.com
;;;
;;; VERSION
;;;  1.0 Oct. 01, 2004
;;;
;;;  This software is provided "as is" without express or implied      ;
;;;  warranty.  All implied warranties of fitness for any particular   ;
;;;  purpose and of merchantability are hereby disclaimed.             ;
;;;  You are hereby granted permission to use, copy and modify this    ;
;;;  software without charge, provided you do so exclusively for       ;
;;;  your own use or for use by others in your organization in the     ;
;;;  performance of their normal duties, and provided further that     ;
;;;  the above copyright notice appears in all copies and both that    ;
;;;  copyright notice and the limited warranty and restricted rights   ;
;;;  notice appear in all supporting documentation.                    ;
;;;
(defun c:re-name-layouts (/ tab_name doc cnt x suffix new_list)
  (vl-load-com)
  (setq tab_name (getstring t "\nEnter Tab Name prefix (add trailing space): "))
  (cond (tab_name) ((setq tab_name "")))
  (initget "Numbers Letters")
  (setq suffix (getkword "\nSuffix to use? [Numbers or Letters] : <Numbers> "))
  (cond (suffix) ((setq suffix "Numbers")))
  (setq *doc* (vla-get-activedocument (vlax-get-acad-object)))

  (vlax-for tab (vla-get-layouts ; get list of layout tabs
                  (vla-get-activedocument (vlax-get-acad-object)))
    (if (/= (setq tmpname (vla-get-name tab)) "Model") ; omit MODEL space
      (setq new_list (cons (cons (vla-get-taborder tab) tab) new_list))
    )
  )
  ;;  sort list acording to tab order
  (setq new_list (vl-sort new_list
                  '(lambda (e1 e2) (< (car e1) (car e2)))))
  ;;remove the taborder numbers
  (setq new_list (mapcar 'cdr new_list))

  ;; rename the tabs
  (setq cnt (cond ((= suffix "Numbers") 0) (64)))
  (foreach x new_list
    (vla-put-name x
       (strcat tab_name
               (cond
                 ((= suffix "Numbers")
                   (itoa (setq cnt (1+ cnt))))
                 ((chr (setq cnt (1+ cnt))))
               )))
  )
  (princ)
) ; defun
(prompt "\n*-*  Rename Tab layouts Loaded, Enter re-name-layouts to run. *-*")
(princ)


CAB,

This is really cool!  Here is a question that I think can it can be done but I don't know where to start.  Please just follow what it is saying.

Ok, lets start with a 4 tabs for sheets
in paper space.  Lets say that you name the 4 tabs BFDS, BFDW, CFP01 and
CFP02.

Now take the shape (dwg area in model) of the view port from the tab BFDS and paste it into model space.

You want that shape (dwg area in model) to match the name of the tab.  So you name the shape (dwg area in model) BFDS with text.

But I want to have that name of shape (dwg area in model) automatically
change with Rtext.  So when you change that tab BFDS to BFINB.

The shape (dwg area in model) will automatically update to BFINB.

That is my question.

How would you do that with the rest of that tabs BFDW, CFP01 and CFP02?  Is there a sequence diesel code for each tab?

danny

  • Guest
rename layout tabs??
« Reply #16 on: October 01, 2004, 05:49:07 PM »
keith,
how do I use your VBA macro.  I have 80 files where some of the layout tabs where renamed and some not.  I would like to rename to layout1 instead of the sheet number, but if it requires opening every dwg I'll have to ignore it.  BrowseForFolder macro?

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
rename layout tabs??
« Reply #17 on: October 01, 2004, 06:52:28 PM »
Oneshot,
What you are asking is possible and i think would require a reactor.
I have not delt with reactors so I can not help you at this time.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
rename layout tabs??
« Reply #18 on: October 01, 2004, 08:29:35 PM »
Quote from: danny
keith,
how do I use your VBA macro.  I have 80 files where some of the layout tabs where renamed and some not.  I would like to rename to layout1 instead of the sheet number, but if it requires opening every dwg I'll have to ignore it.  BrowseForFolder macro?

I'll have to put together that BrowseForFolder macro and post it.... there will be some additional coding required,  but it will streamline the process so that it will all happen in a matter of a couple of minutes, rather than a couple of hours of your time.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

hendie

  • Guest
rename layout tabs??
« Reply #19 on: October 02, 2004, 07:25:22 AM »
Quote from: One Shot

CAB,

This is really cool!  Here is a question that I think can it can be done but I don't know where to start.  Please just follow what it is saying.

Ok, lets start with a 4 tabs for sheets
in paper space.  Lets say that you name the 4 tabs BFDS, BFDW, CFP01 and
CFP02.

Now take the shape (dwg area in model) of the view port from the tab BFDS and paste it into model space.

You want that shape (dwg area in model) to match the name of the tab.  So you name the shape (dwg area in model) BFDS with text.

But I want to have that name of shape (dwg area in model) automatically
change with Rtext.  So when you change that tab BFDS to BFINB.

The shape (dwg area in model) will automatically update to BFINB.

That is my question.

How would you do that with the rest of that tabs BFDW, CFP01 and CFP02?  Is there a sequence diesel code for each tab?


have a look at the A-MTEXT lisp in your Sample > Visual Lisp > Reactors directory. it adds Mtext linked to a circle ~ if you modify the circle, the mtext changes to reflect that. It should be able to be modified to suit your needs.

One Shot

  • Guest
rename layout tabs??
« Reply #20 on: October 04, 2004, 01:26:09 PM »
Quote from: hendie
Quote from: One Shot

CAB,

This is really cool!  Here is a question that I think can it can be done but I don't know where to start.  Please just follow what it is saying.

Ok, lets start with a 4 tabs for sheets
in paper space.  Lets say that you name the 4 tabs BFDS, BFDW, CFP01 and
CFP02.

Now take the shape (dwg area in model) of the view port from the tab BFDS and paste it into model space.

You want that shape (dwg area in model) to match the name of the tab.  So you name the shape (dwg area in model) BFDS with text.

But I want to have that name of shape (dwg area in model) automatically
change with Rtext.  So when you change that tab BFDS to BFINB.

The shape (dwg area in model) will automatically update to BFINB.

That is my question.

How would you do that with the rest of that tabs BFDW, CFP01 and CFP02?  Is there a sequence diesel code for each tab?


have a look at the A-MTEXT lisp in your Sample > Visual Lisp > Reactors directory. it adds Mtext linked to a circle ~ if you modify the circle, the mtext changes to reflect that. It should be able to be modified to suit your needs.


I have the A-Mtext.lisp open and know I am trying to figure out what do I need to change to make it work to my liking.  Can someone help me out?

One Shot

  • Guest
rename layout tabs??
« Reply #21 on: October 12, 2004, 05:44:27 PM »
I have been trying to figures this out.  I am have no luck with it.  Can someone help me out?  Thank you!

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

ELOQUINTET

  • Guest
rename layout tabs??
« Reply #24 on: October 13, 2004, 12:39:47 PM »
cab just used your rename routine wooooow works beautifully

CADaver

  • Guest
rename layout tabs??
« Reply #25 on: October 13, 2004, 01:29:37 PM »
Okay, I have to ask the question.  I tried not to, but I just can't help it, I gotta know.  

What the heck is the advantage in changing the name of the layout tab back to layout1?

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
rename layout tabs??
« Reply #26 on: October 13, 2004, 02:23:39 PM »
got me... but you know I don't usually question why someone would like to do something .. perhaps I should ... but when it has absolutely no bearing on me, I couldn't care less
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

pmvliet

  • Guest
rename layout tabs??
« Reply #27 on: October 13, 2004, 02:27:41 PM »
Well I have a couple reasons:

First I have a 1-button routine that will plot to any device/size paper
but it requires that Layout1 is named Layout 1

Secondly, when you create a plot file or PDF, AutoCad will put the file name and then put a -layout name. For a drawings named A-101.dwg
with a layout called A-101, the plot file is A-101-A-101.plt. It gets to be a real nuisance.

Third, I see no real value and just takes time and more upkeep in a drawing. As soon as you do a saveas, if you don't go and update your layout name you will start getting inconsistencies. It just leads to errors.

Pieter

One Shot

  • Guest
rename layout tabs??
« Reply #28 on: October 13, 2004, 02:33:11 PM »
Quote from: pmvliet
Well I have a couple reasons:

First I have a 1-button routine that will plot to any device/size paper
but it requires that Layout1 is named Layout 1

Secondly, when you create a plot file or PDF, AutoCad will put the file name and then put a -layout name. For a drawings named A-101.dwg
with a layout called A-101, the plot file is A-101-A-101.plt. It gets to be a real nuisance.

Third, I see no real value and just takes time and more upkeep in a drawing. As soon as you do a saveas, if you don't go and update your layout name you will start getting inconsistencies. It just leads to errors.

Pieter



try this string with RText.  This is set to read the file name and then tab name.  Look at the RText where you put it.  I should only say A-101.  So when you plt the file, it will say A-101.plt.

$(substr,$(getvar,"dwgname"),1,$(-,$(strlen,($(getvar,"dwgname"))),6))$(getvar,"ctab")

ronjonp

  • Needs a day job
  • Posts: 7528
rename layout tabs??
« Reply #29 on: October 13, 2004, 05:13:25 PM »
I added a dialogue box to Keith's VBA routine and also added the suffix option like CAB's lisp. Edit: Also added a start number so you could designate what number you want the first tab to start numbering from.

http://theswamp.org/lilly.pond/Ron/rename.bmp

Here is the dvb:
http://theswamp.org/lilly.pond/Ron/rename_tabs.dvb


To run it, type -vbarun then renametabs.

For button access ^C^C-vbarun;renametabs;

Ron :D

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

CADaver

  • Guest
rename layout tabs??
« Reply #30 on: October 13, 2004, 06:49:57 PM »
Quote from: pmvliet
Well I have a couple reasons:

First I have a 1-button routine that will plot to any device/size paper
but it requires that Layout1 is named Layout 1
What happens to layout2??  BTW, look for PLOTTABS on these boards somewhere excellant tool for multiple layouts.

Quote from: pmvliet
Secondly, when you create a plot file or PDF, AutoCad will put the file name and then put a -layout name. For a drawings named A-101.dwg with a layout called A-101, the plot file is A-101-A-101.plt. It gets to be a real nuisance.
Only if you accept the default at plotting.

Quote from: pmvliet
Third, I see no real value and just takes time and more upkeep in a drawing. As soon as you do a saveas, if you don't go and update your layout name you will start getting inconsistencies. It just leads to errors.
If you name the layout something too specific and have to rename it, yes it takes time.  Or if you're going to rename the layout back to "Layout1, it takes time.  We use file numbers and Sheet numbers, the layouts are named after the sheet numbers and the file is the file name.  Accepting the default at plotting, we get <filename>-<sheetname> for individual pdf's.

 We don't use SAVEAS, it brings all the previous drawing TIME with it.  We'll use a previous drawing as a prototype.

carry on, just curious.

ronjonp

  • Needs a day job
  • Posts: 7528
rename layout tabs??
« Reply #31 on: October 14, 2004, 09:51:37 AM »
Just wanted to let you guys know I updated the vba routine to allow the user to designate a number to start numbering from. Check it out

http://theswamp.org/phpBB2/viewtopic.php?p=34725#34725

Ron   :D

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC