• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    AutoCAD 2007/2008/2009 DWG Format

    Reply
    New Member
    Posts: 2
    Registered: ‎06-22-2012

    Lisp Routine to rename All the Layouts

    762 Views, 6 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

    Please use plain text.
    Distinguished Mentor
    Moshe-A
    Posts: 679
    Registered: ‎09-14-2003

    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

     

    Please use plain text.
    Valued Contributor
    TexShalter
    Posts: 52
    Registered: ‎06-18-2010

    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.

    Please use plain text.
    New Member
    Posts: 2
    Registered: ‎06-22-2012

    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

    Please use plain text.
    Distinguished Mentor
    Moshe-A
    Posts: 679
    Registered: ‎09-14-2003

    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

     

     

    Please use plain text.
    Valued Contributor
    bodhran
    Posts: 69
    Registered: ‎10-14-2010

    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

    Please use plain text.
    Valued Contributor
    bodhran
    Posts: 69
    Registered: ‎10-14-2010

    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.

     

     

    

    Please use plain text.