Lisp Routine to Rename and delete autocad layout tabs

Lisp Routine to Rename and delete autocad layout tabs

emilio24DRY
Enthusiast Enthusiast
1,615 Views
9 Replies
Message 1 of 10

Lisp Routine to Rename and delete autocad layout tabs

emilio24DRY
Enthusiast
Enthusiast

1) Rename Layout Tab

I have a drawing with with "Model" "C-5.1" and "C-5.2" Layout Tabs. I need to rename the "C-5.2" to "C-6.2" in multiple drawings within a custom lisp routine that I already have.

 

2) Delete Layout Tab

I have a drawing with with "Model" "C-2.1", "C-2.1" and "C-2.3" Layout Tabs. I need to delete "C-2.1" from a drawing that has been "save as" through a lisp routine.

 

I know that both of these task are simple to do by hand, but I would rather not deal with it manually within our template setup if possible.

0 Likes
Accepted solutions (2)
1,616 Views
9 Replies
Replies (9)
Message 2 of 10

scot-65
Advisor
Advisor
Accepted solution

1.

I'll let you build on this.

(vla-put-Name (vla-Item (vla-get-Layouts *DOC*) orig) a)

orig= original layout name.

a= new layout name [first check for illegal characters, duplicate names, etc.].

*DOC*= (vla-get-ActiveDocument (vlax-get-acad-object))

 

RNLT_RenameLayoutTab-1.gif

 

2.

(defun c:DLT () (command-s "-Layout" "delete" "")(princ))

Must be in the current layout.

I use this all the time.

 

Hope this helps.

 


Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.

0 Likes
Message 3 of 10

paullimapa
Mentor
Mentor
Accepted solution

Assuming those layout names do exists and there won't be a duplicate when one is renamed then you can run this sequence of commands:

-Layout _Rename C-5.2 C-6.2 -Layout _Delete C-2.1

Then use Lee Mac's Script Writer to automate the process and apply it to all dwgs in a given folder:

Script Writer | Lee Mac Programming (lee-mac.com)

 

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 4 of 10

pbejse
Mentor
Mentor

@emilio24DRY wrote:

1) Rename Layout Tab

I have a drawing with with "Model" "C-5.1" and "C-5.2" Layout Tabs. I need to rename the "C-5.2" to "C-6.2" in multiple drawings within a custom lisp routine that I already have.

 

2) Delete Layout Tab

I have a drawing with with "Model" "C-2.1", "C-2.1" and "C-2.3" Layout Tabs. I need to delete "C-2.1" from a drawing that has been "save as" through a lisp routine.


There will be two programs? one rename and another to delete layout tabs? on the current drawing session for item 2?

Would you mind sharing the routine here?

 

0 Likes
Message 5 of 10

jcarter33T87
Explorer
Explorer

I would simply use sheetsetmanager (sheetset).  This allows you to rename/renumber sheets as needed and it will update the layout tabs.  You can't delete the layout tabs through this, but they can easily be renamed.

 

jcarter33T87_0-1721235064581.png

 

This is just an example.

0 Likes
Message 6 of 10

emilio24DRY
Enthusiast
Enthusiast
This is perfect. Thanks!
0 Likes
Message 7 of 10

emilio24DRY
Enthusiast
Enthusiast

The "-layout" command is what I was looking for. I am just adding this command line into the rest of my code. But they are separate commands for different areas of my code.

0 Likes
Message 8 of 10

emilio24DRY
Enthusiast
Enthusiast

This is another way of doing it-I just didn't want to have to do it manually.

0 Likes
Message 9 of 10

jcarter33T87
Explorer
Explorer
Understood. I used it everyday. All my sheets and templates for new projects are set up using sheetset. That way, I do it once in the beginning (using fielded mtext for sheet titles and numbers) then it's simple to rename easily. Fought it for years, finally in 2010 I decided to try it. Worked well, self taught.
0 Likes
Message 10 of 10

paullimapa
Mentor
Mentor

glad to have helped...cheers!!!


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes