Author Topic: rename layout tabs??  (Read 14582 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.