TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Lonnie on June 10, 2021, 05:25:28 PM

Title: Publish formating question. Changing the -
Post by: Lonnie on June 10, 2021, 05:25:28 PM
I tried the autodesk forum many years ago on this one. Stealing this right out of my question.

I have a client requesting we change our dwf file names. This will be an ongoing thing. Say 1,000 sets with 8 sheets per set so it's worth a little time for me to figure this out.

 

When you publish file name + view name you get.

3610 - PLANS AND DETAILS-3515.dwf

I want to change it to.
3610 - PLANS AND DETAILS - 3515.dwf

It's the space around the last - that we need.
DETAILS - 3515

 

My quick question would be.

Since acad is putting the - can you get to it in any way shape or form?

https://forums.autodesk.com/t5/autocad-forum/publish-formating-question-changing-the/m-p/7725000#M917261
Title: Re: Publish formating question. Changing the -
Post by: JohnK on June 10, 2021, 05:38:32 PM
I would use a batchscript to do this. I’m not at a pc at the moment but I would look at the thread I had a few years ago about using XPS instead of PDF/etc. I had some file renaming in one of those scripts. I can get you more whenever I get back on a pc.

https://www.theswamp.org/index.php?topic=50646.0
Title: Re: Publish formating question. Changing the -
Post by: JohnK on June 10, 2021, 05:58:24 PM
Real quick (I have to run). I coded this blind and I have no way of testing it yet so you will have to be the tester.

You would have to save this to a file called (or something of your choosing) in a directory with some files: "renameabunchofstufffortheclient.bat"

Double click and your files should rename (I hope).

Code - Bash: [Select]
  1. @echo off
  2.  
  3. pushd "%~p1"
  4. setlocal enabledelayedexpansion
  5.  
  6. for /f "tokens=1-4 delims=-." %%a in ("%%~nxf") do (
  7.  
  8.         echo. Name has been delimited:
  9.         echo. a is "%%a" b is "%%b" c is "%%c"
  10.  
  11.         IF NOT %%a=="" (
  12.  
  13.                 set number=%%a
  14.                 set type=%%b
  15.                 set number=%%c
  16.                 set ext=%%d
  17.                 set namestring="!number! - !type! - !number!.!ext!"
  18.                 echo. Target name is: !namestring!
  19.                 ren %%f !namestring!
  20.                 echo. %%f has been renamed to !namestring!
  21.  
  22.         )
  23.  
Title: Re: Publish formating question. Changing the -
Post by: Lonnie on June 10, 2021, 06:03:27 PM
I will see if it works in the morning.

Thank you.
Title: Re: Publish formating question. Changing the -
Post by: BIGAL on June 10, 2021, 06:47:00 PM
From Autodesk renames a file
(vl-file-rename  old-filename new-filename)

There is lisp for get a list of dwgs from a selected directory.

It would be feasible to use accoreconsole where the script/lisp calls a plot lisp that saves the dwf with correct name so no need to do a rename, only thing is the plot lisp part picking plot area. For us with a fixed title block not a problem.
Title: Re: Publish formating question. Changing the -
Post by: JohnK on June 10, 2021, 09:08:45 PM
But if you already have a set of plot files, what would be the point to plotting 8,000 sheets just to change a name? Or only limit yourself to one method of plotting (only with a script instead of a sheet set or publish list)? ...windows can rename those files in seconds vs hours to replot.
Title: Re: Publish formating question. Changing the -
Post by: Lonnie on June 11, 2021, 09:11:48 AM
This is an ongoing thing. We publish about 20 of these sets each week. The client was ok with no space between the sheet name and the dwg name for 10 years. Now they want spaces on each side. We do it with the renamer softerware after the fact but it sure would be nice to have AutoCAD publish the correct syntax.
Once again it's AutoCAD putting the "-" between sheetview name and dwg name that is the problem.  What adds to the problem is there is an earlier "-" in the sheet name.

No one in the AutoDesk forums could help. You all are so eclectic group I was hoping for some out of the box answer.
Title: Re: Publish formating question. Changing the -
Post by: BIGAL on June 13, 2021, 07:48:46 PM
When you say plot 20 sets a week what is a set made up of ?

A single dwg with certain layouts ? Multiple dwgs all layouts ?

Do you have a fixed title block always the same ?

Can the layout name be what you want ? Lisp for that exists.

The more info the more chances of a single solution.
Title: Re: Publish formating question. Changing the -
Post by: Lonnie on June 14, 2021, 10:52:00 AM
Good questions.

A set is made up of 8 separate dwg's. No dwg has over two layouts that will be used printed. All printed sheets are layouts.

Layouts are derived off usage "-" sheet name "-" dwg name. (Dwg name is the job number.)

Titleblocks are interesting. We reference them in and they have attributes, fields and parametric blocks that are burst to show certain features once they are attached to a project. Depending on the type of project the same block could have nested parametric block up to 8 deep.

So

3610 - PLANS AND DETAILS-3515.dwf

would translate to

project - sheet name - Address

The file structure would be.

\\unc\year\project\address\cadd\3515.dwg