Jump to content
DVDM

Batch rename of layouts

Recommended Posts

DVDM

Hi all,

 

I have looked just about everywhere for this, and I seem to be the only one out who would want such a thing.

 

Here it goes.

 

We have about 20.000 drawings, and each drawing has between 1 and 40 layouts. The vast majority of drawings have layout names like 01, 02, 03 etc, or -01, -02, -03 etc. A 50/50 split, it really depended on the personal preference of the person creating the layouts.

Now it's been decided to stick to (and enforce) the -01, -02, -03 naming convention, for technical reasons.

That means that whenever someone encounters an older drawing that will be used in a new project, they have to manually change the layout names one by one.

 

A start would be to find a way to batch rename a set of layout names in an individual drawing, but I haven't even been able to find that.

Something similar to a batch rename on a set of files, where it's be a piece of cake so convert everything from 01 to -01.

Unfortunately the RENAME command does not allow changing layout names, and so far I have not been able to find anything else that does.

 

The next step would be to do run a batch on entire directories, perhaps using something like Multi Batch 9.0, but so far I haven't seen any built in functionality for this program.

 

Does anyone have any idea where to start?

Share this post


Link to post
Share on other sites
ReMark

You're looking at it the wrong way. Yes, you want to Rename a layout but it is done through the LAYOUT command (as an option) and not directly through the RENAME command.

 

To see what I mean try typing LAYOUT at the command line. See the option for RENAME? OK, not type 'R' (for rename) and see what the prompt says? That's the basic starting point for your LISP or VBA program. I'm sure someone has written a program that does exactly what you are looking to accomplish. Now all you have to do is find it. Have you tried over at Cadalyst Magazine and it's CAD Tips section for AutoLISP and VBA?

Share this post


Link to post
Share on other sites
ReMark

OK...I lied. This is the last one. Take your choice of above and combine with the LISP routine for handling batch processing of AutoCAD drawings and you've got yourself a winner. Look at BS.LSP.

 

http://www.simplecad.com/lisp/lispfile.htm

Share this post


Link to post
Share on other sites
DVDM

Thanks ReMark, there was a lot of useful info in there.

It looks like all roads lead to LISP for this one. I'm going to have to dig a bit deeper into the inner workings of LISP.

Some of these examples are tantalisingly close to what I want it to do.

The find/replace routine has been quite helpful already in another layout-naming problem that we sometimes encounter in some of our older files.

 

Again, thanks for your help. I'm sure I can make something out of this that works for exactly how I want it.

Share this post


Link to post
Share on other sites
ReMark

Happy to be of some small service. When you arrive at a final solution post back to keep us updated.

Share this post


Link to post
Share on other sites
DVDM

Well, I have found a solution that works quite well, and did not require any further LISP knowledge on my behalf.

The basis was multi-batch, which basically lets you set up a commandline-routine, and then apply this to a whole set of files.

I'm using this program in conjunction with Find/Replace lisp routine mentioned earlier in the thread. It's a very 'dumb' routine, and it can probably be done with more intelligence using a LISP routine with 'if' statements. However, with a bit of cutting and pasting I had the routine below in a matter of minutes, and was able to incorporate a font change while I'm at it.

I basically invoke the TABRENAME.LSP routine 118 times to do just about every possible variation found in our Layout names. It looks like this:

 
;Rename Layouts
;This Routine only works when TABRENAME.LSP is loaded.
TBR Layout -0 Y
;Any existing instances of -01, -02 etc. will be renamed to 01, 02
TBR -01 01 Y TBR -02 02 Y TBR -03 03 Y TBR -04 04 Y TBR -05 05 Y TBR -06 06 Y TBR -07 07 Y TBR -08 08 Y
TBR -09 09 Y TBR -10 10 Y TBR -11 11 Y TBR -12 12 Y TBR -13 13 Y TBR -14 14 Y TBR -15 15 Y TBR -16 16 Y
TBR -17 17 Y TBR -18 18 Y TBR -19 19 Y TBR -20 20 Y TBR -21 21 Y TBR -22 22 Y TBR -23 23 Y TBR -24 24 Y
TBR -25 25 Y TBR -26 26 Y TBR -27 27 Y TBR -28 28 Y TBR -29 29 Y TBR -30 30 Y TBR -31 31 Y TBR -32 32 Y
;Now that all existing dashes are removed, all tabs can be renamed to the correct tab name i.e. -01, -02.
TBR 01 -01 Y TBR 02 -02 Y TBR 03 -03 Y TBR 04 -04 Y TBR 05 -05 Y TBR 06 -06 Y TBR 07 -07 Y TBR 08 -08 Y
TBR 09 -09 Y TBR 10 -10 Y TBR 11 -11 Y TBR 12 -12 Y TBR 13 -13 Y TBR 14 -14 Y TBR 15 -15 Y TBR 16 -16 Y
TBR 17 -17 Y TBR 18 -18 Y TBR 19 -19 Y TBR 20 -20 Y TBR 21 -21 Y TBR 22 -22 Y TBR 23 -23 Y TBR 24 -24 Y
TBR 25 -25 Y TBR 26 -26 Y TBR 27 -27 Y TBR 28 -28 Y TBR 29 -29 Y TBR 30 -30 Y TBR 31 -31 Y TBR 32 -32 Y
TBR A4-01 -01 Y TBR A3-01 -01 Y TBR A2-01 -01 Y TBR A1-01 -01 Y TBR A0-01 -01 Y TBR B1-01 -01 Y
TBR A4-02 -02 Y TBR A3-02 -02 Y TBR A2-02 -02 Y TBR A1-02 -02 Y TBR A0-02 -02 Y TBR B1-02 -02 Y
TBR A4-03 -03 Y TBR A3-03 -03 Y TBR A2-03 -03 Y TBR A1-03 -03 Y TBR A0-03 -03 Y TBR B1-03 -03 Y
TBR A4-04 -04 Y TBR A3-04 -04 Y TBR A2-04 -04 Y TBR A1-04 -04 Y TBR A0-04 -04 Y TBR B1-04 -04 Y
TBR A4-05 -05 Y TBR A3-05 -05 Y TBR A2-05 -05 Y TBR A1-05 -05 Y TBR A0-05 -05 Y TBR B1-05 -05 Y
TBR A4-06 -06 Y TBR A3-06 -06 Y TBR A2-06 -06 Y TBR A1-06 -06 Y TBR A0-06 -06 Y TBR B1-06 -06 Y
TBR Sht-01 -01 Y TBR Sht-02 -02 Y TBR Sht-03 -03 Y TBR Sht-04 -04 Y TBR Sht-05 -05 Y TBR Sht-06 -06 Y
TBR Sheet1 -01 Y TBR Sheet2 -02 Y TBR Sheet3 -03 Y TBR Sheet4 -04 Y TBR Sheet5 -05 Y TBR Sheet6 -06 Y
TBR Sheet-01 -01 Y TBR Sheet-02 -02 Y TBR Sheet-03 -03 Y TBR Sheet-04 -04 Y TBR Sheet-05 -05 Y
;Changes the font for the standard style in drawings
_style
Standard
isocp




_qsave
_redraw

 

The routine runs through every file in about 2 to 3 seconds, and so far I've converted 6000 files, just letting autocad crunch away in the background while I get on with my job.

It's got a drawback; it can not convert layout names with spaces in them. So a layout called 'Sheet 01' can not be renamed properly, and currently gets renamed to 'Sheet -01'. But this is less than 1% of the drawings, so thats a problem I'll tackle later on.

Share this post


Link to post
Share on other sites
firsrate_caduser

HELLO DVDM!

 

I am interested to batch changing layout tab, I have about 5000 dwgs to change and I come a cross with your post. I tried to follow your instruction without any luck...can you please help me and show how did you combine you code with the tabrename.lsp.

 

thanks a lot for you help!!

Share this post


Link to post
Share on other sites
DVDM

Hi firstrate_caduser,

 

Can you tell me what type of rename you'd like to do? If your existing layout names contain spaces i might not be able to help you.

I'll write down a step by step description detailing what I did soon.

Share this post


Link to post
Share on other sites
firsrate_caduser

thanks for you reply!! and sorry for no have replied earlier...you know did not work over the weekend.

 

See, here the scenario, a customer provided a templated with a layout tab named (11X17 HPLJ) and also with plotting setting already set. however, the drawing is an old template which has somemany issues so I created my own templated, unfortuanally I named the layout (11X!& HPLJ) and not pet attention to the printing seeting.

 

Now the problem is that already almost finished all the drawings for the project and there are somemany! so I was thinking to find a lsp to that for me, but now I am thinking that I need the plotting settings...mmm!!

 

 

also what you said that there is spaces in the name.

 

I gues, have to use the design center and open every single drawing and drag and drop the layout.

 

unless you know a way to do that with lsp.

 

thanks for you help!!

Share this post


Link to post
Share on other sites
DVDM

I was actually able to find a solution for names with spaces, although for your situation the space doesn’t matter at all. Here’s how you do it.

 

Download the TABRENAME.LSP file (http://www.ramlug.org/index.php?option=com_docman&task=doc_details&gid=18&Itemid=55) and save it somewhere on your computer or network. Make sure that that lisp file gets loaded every time you open a document. You don’t have to edit the lisp code at all.

Not sure how that goes in the Acad version you are using. In Acad 2009 you type in CUI, and add the file to the Lisp – section (see screenshot). You can load it for an individual document by typing APPLOAD and loading the file, but you don’t want to be doing that every single time you open a document.

 

If the lisp routine is loaded successfully, you should be able to type the command TBR. It will then ask you ‘Find:’ (type in what you want to have replaced), followed by ‘Replace:’

In your example you could just replace 11X!& with 11X17, because the space and what comes after it can stay where it is. (In my situation, I wanted to rename ‘Sheet -01’ to ‘-01’, but didn’t know how to remove the space until now)

If the name contains spaces you want to include, you put the text in between “ “. In your case you could enter “11X!& HPLJ” and replace by “11X17 BLAH” if you wanted to.

 

This is all done through the command line, which is what you want if you were to automate this process and run a batch on a whole set of drawings.

As I mentioned earlier in the thread I bought a program called Multi-Batch 9.0 (www.multi-batch.com). A single user license costs $39. It works brilliantly, because all you need is an understanding of how the command line works. You simply create a command line routine that you want to run on a set of files, then you set the directory containing all your files (it can include files in subdirectories), and you assign your routine to all of these files with one click.

The routine would look something like this:

 

TBR 11X!& 11X17 Y (Note: Every single space in the routine is an ‘execute’, just like in your command line, which is why spaces were causing me problems in the routine previously)

 

 

_QSAVE

_REDRAW (I’m not sure of the significance of this command after the save, but most of the pre-loaded routines have it so I left it there)

 

 

Once you hit Start you watch it crunch through your files. The program starts up your own Autocad, opens the file, runs the routine, then saves it. This means it’s not some back-door conversion by a third-party application, which might cause problems with the file.

I’ve processed 25000 files this way, and with the long routine I had assigned to them (see previous page) it did about 20 to 25 drawings per minute. I usually ran it during the day, because every now and then I came across an old dodgy file that had an error (and needed a RECOVER), which would stop the entire process.

Obviously, you do a test run on a few files to make sure the end result is what you want before you do all 5000. There’s a fully functional trial available that’s limited to 3 files per batch.

 

About the plot-settings; multi-batch does have a tab where you can set plot settings, but I’m not sure how this works.

It can probably be done through the command line however, using the –plot command (with the ‘-‘ in front it doesn’t bring up a dialogue box, and keeps your plot options command line based)

In multibatch it could look something like this:

 
_-PLOT
_Y
“11X17 HPLJ” (This line doesn’t accept spaces, hence the layout name between “ “)
Your Plotter Name.pc3 (This line does accept spaces, so “ “ not required here)
Your Page Size
_I
_L
_N
_E
_1:1
_C
_Y
Your Plotstyle.ctb
_Y
_N
_N
_N
_N
_Y (Saves the plot settings)
_N (Doesn’t proceed with the plot, unless you want 5000 actual plots)
_qsave
_redraw

 

The line above can simply be combined with the previous routine (after renaming the layout). I'm not really sure about the significance of the underscore in front of commands, but it does seem to work better for certain commands.

Any questions, let me know.

CUI.jpg

MB9.jpg

ROUTINE.jpg

Share this post


Link to post
Share on other sites
firsrate_caduser

WOW!

 

Thanks you very much for your information. I will getting that batch program for future needs...I do not know much about lsp, so with this program would be easy to do what I wanted to do.

 

thanks again for the info, this would be save a lot of time to edit all those drawing.

 

 

cheers!!!

Share this post


Link to post
Share on other sites
Mystogan

Trying my best to revive this thread... Can someone post the TABRENAME.LSP

 

Pls I need the code so I can do Batch rename layout... Can assess ramlug.org

Share this post


Link to post
Share on other sites
ReMark
Trying my best to revive this thread... Can someone post the TABRENAME.LSP

 

Pls I need the code so I can do Batch rename layout... Can assess ramlug.org

 

You didn't stop to consider just doing an Internet search on the name of the lisp routine did you? Seek and ye shall find.

 

http://www.ramlug.org/downloads/TABRENAME.LSP

Share this post


Link to post
Share on other sites
Mystogan

Hi sir ReMark Thank you very much for your effort.. I tried to click the linked on the previous page. Unfortunately, The link requires to be a member to be able see the page. I usually got the Page Can't reach something .....

 

 

With your link I finally got the code for rename layout.

 

Once again thank you very much

Share this post


Link to post
Share on other sites
BIGAL

Re preloading the tabrename lsp, just do just that as say a 1st line in the script file

 

(if (not TBR)(load "tabrename"))

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...