Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

rename layout tabs

27 REPLIES 27
Reply
Message 1 of 28
GavrielKing
2134 Views, 27 Replies

rename layout tabs

Does anyone know if it is possible to write a lisp or script that will open an entire directory of drawings and automatically rename all of the layout tabs (even if there are multiple layout tabs in a certain drawing file) to include a period "." at the end of the tab name? I need this work in AutoCAD 2009 and 2010. Any advice is greatly appreciated. Tank you.
27 REPLIES 27
Message 2 of 28
Anonymous
in reply to: GavrielKing

You can run something like this with ScriptPro (free from AutoDesk)

(defun c:renamelayout (/ laylist)
(setq laylist (layoutlist))
(foreach x laylist
(command "layout" "R" x (strcat x "."))
)
(princ)
)
Message 3 of 28
GavrielKing
in reply to: GavrielKing

Thank you very much! I didn't even need ScriptPro. I simply loaded your lisp routine, and ran it, and it worked!

However, I need to be able to have this routine automatically open an entire directory of drawing files and add the period to the tabs, as opposed to opening each drawing file individually and running the routine each time.

I am sure this is possible, I just don't have the knoweledge to write the routine to make it happen.

Thanks again!
Message 4 of 28
stevor
in reply to: GavrielKing

Then you did need Script Pro, just like he said.

Or make your own script; or possibly by other ways.
S
Message 5 of 28
GavrielKing
in reply to: GavrielKing

Ok. I will get ScriptPro and see if I can figure it out. Thank you.
Message 6 of 28
Anonymous
in reply to: GavrielKing

You could also add a (command "_.save" "" "_.close") line at the end of that
code, put everything in the ACADDOC.LSP file
and then just drag and drop your files in a removable amount, like by 20 or
something until you are done. If the close part isn't working, you could use
the Closeall command manually.

HTH



--
Humans are born with a wide horizon.
As time goes by, the horizon narrows and
narrows, until it becomes a point of view.


a écrit dans le message de news:
6307066@discussion.autodesk.com...
Ok. I will get ScriptPro and see if I can figure it out. Thank you.
Message 7 of 28
GavrielKing
in reply to: GavrielKing

Thank you for your suggestion, but I got lost at "and then just drag and drop..."
Message 8 of 28
Anonymous
in reply to: GavrielKing

Well you have a folder with the drawings, then you have your AutoCAD
application and just make sure that it is in mode MDI (Multiple Documents
Interface). Close all your documents, then multiple select DWGg files in the
folder and drag and drop them in your AutoCAD application. They will open
one by one and will run the code from ACADDOC.LSP. Start with few drawings
in order to understand how it works.

And I think that it's a good idea to wrap all that code in a S::STARTUP
function in order to make sure that everything it's done only when the
documents are 100% initialized.

Hope it makes sense for you.


--
Humans are born with a wide horizon.
As time goes by, the horizon narrows and
narrows, until it becomes a point of view.


a écrit dans le message de news:
6307084@discussion.autodesk.com...
Thank you for your suggestion, but I got lost at "and then just drag and
drop..."
Message 9 of 28
Anonymous
in reply to: GavrielKing

As I said, there should be no opened document when you do the drag&drop
stuff in AutoCAD, but if it happens to have an opened document, just make
sure you don't drop the DWG files over the graphic screen (this is like
inserting them as blocks), but rather in the Command area.

--
Humans are born with a wide horizon.
As time goes by, the horizon narrows and
narrows, until it becomes a point of view.


a écrit dans le message de news:
6307084@discussion.autodesk.com...
Thank you for your suggestion, but I got lost at "and then just drag and
drop..."
Message 10 of 28
GavrielKing
in reply to: GavrielKing

Thank you for your help, but it's not working. I added the following:

(defun c:RL (/ laylist)
(setq laylist (layoutlist))
(foreach x laylist
(command "layout" "R" x (strcat x "."))
)
(princ)
)

(command "_.save" "" "_.close")

into my acaddoc.lsp file and when I open AutoCAD and go to the text window, I see the following, ".save Save drawing as <>: A drawing with this name already exists. Do you want to replace it? _.close Yes or No, please. ; error: Function Cancelled A drawing with this name already exists. Do you want to replace it? "

And when I drag a drawing file into the command line, it opens the drawing and just sits there. It doesn't rename the layout tabs.
Message 11 of 28
GavrielKing
in reply to: GavrielKing

I just tried to search for ScripPro on Autodesk's website and I couldn't find it. Do you know how I can get it?
Message 12 of 28
Anonymous
in reply to: GavrielKing

Use to be in Migration Tools here
http://usa.autodesk.com/adsk/servlet/index?siteID=123112&id=4091668&linkID=9240618
But Can't find it so they may have done away with it. May have to use a 3rd
party program or use Some Buddy's trick
BTW, you'll have to run it without the lisp call in the acaddoc.lsp
something like this:

(setq laylist (layoutlist))
(foreach x laylist
(command "layout" "R" x (strcat x ".")))
(command "_.save" "" "_.close" "Y")
Message 13 of 28
Anonymous
in reply to: GavrielKing

Ah, here it is
http://usa.autodesk.com/adsk/servlet/item?siteID=123112&id=4091678&linkID=9240618
Message 14 of 28
GavrielKing
in reply to: GavrielKing

It is still not working correctly. I replaced what I had in myacaddoc.lsp file with the following:

(setq laylist (layoutlist))
(foreach x laylist
(command "layout" "R" x (strcat x "."))) (command "_.save" "" "_.close" "Y")

When I first open AutoCAD and go to the text window, I see the following:

layout Enter layout option [Copy/Delete/New/Template/Rename/SAveas/Set/?] : R Enter layout to rename : Layout1 Enter new layout name: Layout1. Layout "Layout1" renamed to "Layout1.". _.save Save drawing as <>: A drawing with this name already exists. Do you want to replace it? _.close Yes or No, please. ; error: Function cancelled A drawing with this name already exists. Do you want to replace it?


And when I drag a couple of AutoCAD drawing files onto my command line, it opens and the drawings and adds the period to each layout tab, but it leaves the drawings open. I thought it was supposed to close and save them.
Message 15 of 28
GavrielKing
in reply to: GavrielKing

Cool! Thank you. I will try it out.
Message 16 of 28
GavrielKing
in reply to: GavrielKing

I have attached a lisp routine that someone made for me that purges an entire directory of drawing files. Do you think you could modify this routine to add the renaming of the layout tabs? I tried, but I can't figure out how to add in the code for the tab renaming. I sure would appreciate it!
Message 17 of 28
biscuits
in reply to: GavrielKing

Try this


(command "_.qsave" "" "_.close" "Y")
Message 18 of 28
GavrielKing
in reply to: GavrielKing

Thanks for the suggestion, but that didn't work either. As soon as I open AutoCAD, my default drawing that I use to open AutoCAD (etransmit.dwg) closes and the AutoCAD help menu pops up. And if I simply open AutoCAD from the program files folder, the help menu still pops up and I still see the following in the text window:

_.qsave Save drawing as
<>: A drawing with this name already
exists.
Do you want to replace it? _.close
Yes or No, please.
; error: Function cancelled
A drawing with this name already exists.
Do you want to replace it?

And when I drag an AutoCAD file into my command line to rename the layout tab, it opens the drawing and then closes it, but it does not rename the layout tab. It seems like there should be a way to incorporate the "RENAMELAYOUT" lisp routine into my "PURGED" lisp routine so that all I have to do is enter a command and choose a directory and it will automatically open each drawing in that directory, rename the layout tabs and close the drawings.
Message 19 of 28
GavrielKing
in reply to: GavrielKing

From what I can tell, if I use ScriptPro, I have to specify exactly which drawing files I want to run my lisp routines on. But I would like to simply specify the directory to where the drawing files are, because it will always be different.
Message 20 of 28
Anonymous
in reply to: GavrielKing

Been a while since I used ScriptPro but I think you can drag the directory
into the window from explorer.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost