AutoCAD 2007/2008/2009

Reply
New Member
niket99
Posts: 2
Registered: ‎06-22-2012
Message 1 of 8 (1,789 Views)

Lisp Routine to rename All the Layouts

1789 Views, 7 Replies
06-22-2012 04:38 AM

Hi all, 

 

I am new to this stuff and dont know if this has been asked before or not. I am looking for a lisp routine that allows me to rename my layouts without opening the drawing itself.

 

kind regards

 

nick

Distinguished Mentor
Moshe-A
Posts: 735
Registered: ‎09-14-2003
Message 2 of 8 (1,772 Views)

Re: Lisp Routine to rename All the Layouts

06-22-2012 12:54 PM in reply to: niket99

Nick,

 

provide more details on what you plan to do?

does the existing layouts names are known in advance?

do you have many files that need to be layouts rename?

 

Moshe

 

Valued Contributor
TexShalter
Posts: 75
Registered: ‎06-18-2010
Message 3 of 8 (1,768 Views)

Re: Lisp Routine to rename All the Layouts

06-22-2012 02:21 PM in reply to: Moshe-A

thanks Moshe,

 

Tried LAYOUTMERGE.  It seems to work perfect.

But when I check the merged (original) layout - it deletes the view in that layout, even when I answer the promt not to do so.

 

Maybe that's just my machine or 3rd party software I'm using.

 

Hmm.

New Member
niket99
Posts: 2
Registered: ‎06-22-2012
Message 4 of 8 (1,747 Views)

Re: Lisp Routine to rename All the Layouts

06-23-2012 03:58 AM in reply to: Moshe-A

moshe

 

i have a master file with 20-25 layouts in it.

 

i bring all the layouts with thier viewport settings into the new files. so now there are 20 files with 25 layouts and all layout names are similar in each files.

 

i know the new names but instead of opening each files and manually renaming all layouts  is there a way to rename all the layouts of one drawing in a single go. 

 

regards

 

nick

Distinguished Mentor
Moshe-A
Posts: 735
Registered: ‎09-14-2003
Message 5 of 8 (1,738 Views)

Re: Lisp Routine to rename All the Layouts

06-23-2012 09:07 AM in reply to: niket99

Nick,

 

Yes, but why the same layouts names in diffrent files is a problem?

AutoCAD has no problem in dealing it.

 

the solusion to this can go like this:-

 

create a text lisp file and name it as AutoLayoutRename.lsp and save it on a the folder where all the files are

copy and paste this lisp code and save the file.

 

note that you have to modify the code to replace your new_layout_names^  and the number of new_layout_names^  must fit to the number of existing layouts in each dwg the lisp does not check to see if the lists are match or exist

 

(defun c:AutoLayoutRename (/ new_layout_names^ i oldName)

 (command "undo" "begin")
  
 (setq new_layout_names^ '("Nick1" "Nick2" "Nick3" "Nick4" "Nick5"))

 (setq i 0)
  
 (mapcar 
  '(lambda (oldName)
    (command "_.layout" "rename" oldName (nth i new_layout_names^))
    (setq i (1+ i))
   )
   (layoutlist)
 )

 (command "undo" "end")

 (princ)
)

 

create another text script file call it AutoLayoutRename.scr and save it on a the folder where all the files are

copy and paste this script code and save the file

 

as you can see this is a repeatative code you need to modify it and enter the fix file name (full path) of each

dwg file in my code there are only 3 files so you need to complete it with your files.

 

be careful not to add extra white spaces between commands and it's arguments cause each white space is like pressing the spacebar key and would consider as enter

also do not create empty lines cause these are also consider as enter in scripts

 

 

open "c:\project\files\dwg1"
(load "autolayoutrename")
AutoLayoutRename
qsave
close
open "c:\project\files\dwg2"
(load "autolayoutrename")
AutoLayoutRename
qsave
close
open "c:\project\files\dwg3"
(load "autolayoutrename")
AutoLayoutRename
qsave
close
open...
....
....
....
close

 

to run this invoke the SCRIPT command and select the AutoLayoutRename.scr file and if evrey thing is in place?

it will should the job.

 

Good Luck

Moshe

 

 

Valued Contributor
bodhran
Posts: 69
Registered: ‎10-14-2010
Message 6 of 8 (1,672 Views)

Re: Lisp Routine to rename All the Layouts

07-12-2012 04:20 PM in reply to: niket99

 

I might be under thinking this but couldn't this be achieved with  simple sript??

 

If i read your post correctly what you want to do is re-name layout name from "Original-01" to "New name-01".

 

If so i have an excel spreadsheet that will allow you to create the script, you simply put in the old name (in column B)  and the new name (in column C) and the copy & Paste Special (select skip blanks) into column A.

Then select the contents of Column A and paste into a new notepad file, saveas file with appropriate name and .scr extension.

Then drag and drop into your open file.

Then it's just a matter of changeing the new name and creating a script for each one, if you will re-use or overright the first one if you wont need them again.

 

I've attached the excel file.

 

Hope this helps.

 

B

Valued Contributor
bodhran
Posts: 69
Registered: ‎10-14-2010
Message 7 of 8 (1,671 Views)

Re: Lisp Routine to rename All the Layouts

07-12-2012 04:27 PM in reply to: bodhran

oops forgot ot mention the method of dragging/replicating the new names down through the spreadsheet.

you have to select the cell to sequence and the blank cells below it, and then drag the bottom right corner as normal this will then star tth esequence in the right place and create names in the correct cells.

 

Hopefully the image attached helps explain this.

 

 



Active Contributor
kylei7449
Posts: 32
Registered: ‎10-16-2012
Message 8 of 8 (891 Views)

Re: Lisp Routine to rename All the Layouts

08-08-2013 03:06 PM in reply to: niket99

I'd like to know if anyone has a similar lisp that can create layouts (using my dwt--ie, I would code in the file path) reading data from a csv file??? I would create the drawings ahead of time, all I would need then is to run the lisp and it would create all the layouts in those dwgs.

 

The csv file contains the drawing names in column A and the layout names in column B.  So, what I want to do is run a lisp that will create "n" number of layouts in specific dwgs, using the cell data it reads from column A--which are the drawing names, and then rename all those layouts with the cell data from B--note not to create duplicate (existing) tabs. So I can re-run it later to add new layouts. 

 

The reason for the need is that I work on projects with several hundred layouts--thus the need to create layouts more easily at the beginning. Instead of renaming/deleting a ton of layouts from our template, it would be easier to start with a minimal template and have the lisp create the exact number of layouts we need for the project instead of going back and making hundreds of edits. And, since the csv is created at the beginning of the project, any changes later (adding layouts usually), can easily be done by running the lisp again adding the new layouts. 

 

I'm not a lisp guy otherwise I'd tackle this. Any suggestions? Thx

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community




Connect with AutoCAD

Twitter

Facebook

Blogs

Pinterest

Youtube