Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
Distinguished Contributor
kingmall
Posts: 571
Registered: ‎04-13-2005
Message 1 of 28 (473 Views)

rename layout tabs

473 Views, 27 Replies
12-17-2009 12:02 PM
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.
*Jason Rhymes
Message 2 of 28 (473 Views)

Re: rename layout tabs

12-17-2009 03:11 PM in reply to: kingmall
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)
)
Distinguished Contributor
kingmall
Posts: 571
Registered: ‎04-13-2005
Message 3 of 28 (473 Views)

Re: rename layout tabs

12-18-2009 07:16 AM in reply to: kingmall
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!
Valued Mentor
stevor
Posts: 888
Registered: ‎12-26-2005
Message 4 of 28 (473 Views)

Re: rename layout tabs

12-18-2009 07:44 AM in reply to: kingmall
Then you did need Script Pro, just like he said.

Or make your own script; or possibly by other ways.
S
Distinguished Contributor
kingmall
Posts: 571
Registered: ‎04-13-2005
Message 5 of 28 (473 Views)

Re: rename layout tabs

12-18-2009 07:46 AM in reply to: kingmall
Ok. I will get ScriptPro and see if I can figure it out. Thank you.
*Some Buddy
Message 6 of 28 (473 Views)

Re: rename layout tabs

12-18-2009 08:04 AM in reply to: kingmall
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.
Distinguished Contributor
kingmall
Posts: 571
Registered: ‎04-13-2005
Message 7 of 28 (473 Views)

Re: rename layout tabs

12-18-2009 08:06 AM in reply to: kingmall
Thank you for your suggestion, but I got lost at "and then just drag and drop..."
*Some Buddy
Message 8 of 28 (473 Views)

Re: rename layout tabs

12-18-2009 09:06 AM in reply to: kingmall
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::smileyfrustrated:TARTUP
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..."
*Some Buddy
Message 9 of 28 (473 Views)

Re: rename layout tabs

12-18-2009 09:53 AM in reply to: kingmall
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..."
Distinguished Contributor
kingmall
Posts: 571
Registered: ‎04-13-2005
Message 10 of 28 (473 Views)

Re: rename layout tabs

12-18-2009 11:34 AM in reply to: kingmall
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.
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.