Continue to Site

Welcome to MCAD Central

Join our MCAD Central community forums, the largest resource for MCAD (Mechanical Computer-Aided Design) professionals, including files, forums, jobs, articles, calendar, and more.

pdf filename include revision

jnoval

New member
I need to include revision number in the filename of pdf
of drawings.
PreE drawing name :1234567.drw
Drawing revision: 05
Pdf:1234567~05.pdf

Have anyone done that without input from user.

Today we use ghostscript to print pdf's. This are
creating filenames like this: 1234567.pdf

I know how to get revision no out of ProE into a text
file, but I can't find a way to rename the PDF filenane
from 1234567.pdf to 1234567~05.pdf
 
Getting the revision out and into a text file is more than half the battle. Be careful, I've had issues with assy drawings and with multi model drawings.

I export the files to a dummy, temp directory with a gibberish name that's created during the export process. That way, I can be sure it's not already being used and that it's empty.

Then, execute a dir command for *.pdf files, capturing that to a text file which you can then parse for the file name.

You can then execute a rename command with the file name and the rev you captured earlier.
 
Doug. Thanks

I see your point in using a temp directory. I will use
that idea.

What kind of issues did you have with multi model
drawings. I assume if I craete the parameter text file
from the drawing it does not matter how many models the
drawing have. WE always use same revision for both
drawing and model (That are a company rule). Drawing are
showing both revisions on top of each other.

My ide was as part of the mapkey to create pdf I will
start script to rename the pdf and move final pdf file to
a another folder. If script fail the user will not get
the pdf file in the final folder.

How are you making the rename. Do you have a script that
you can share?
 
My batch files are a series of nested files that do a lot of stuff, would be hard to make sense of outside our environment. I can share soems nippets, I guess:

To find the file name (I use *.ps files):

<div style="margin-left: 40px;">rem ** generate list of post script files
dir /b *.ps > dir.txt

rem ** extract the file name
findstr ".ps" dir.txt > ps.txt
for /F "tokens=1 delims= " %%i in (ps.txt) do set FILENAME=%%~ni
del dir.txt
del ps.txt
</div>
To find the revision string (assumes your parameter name is 'REVISION' and the parameter file is 'param_temp.txt.1':

<div style="margin-left: 40px;">rem ** Find the drawing revision in the parameter file.
findstr "REVISION" param_temp.txt.1 > rev.txt
for /F "tokens=3 delims= " %%i in (rev.txt) do set REVISION=%%~i
del rev.txt
</div>
My process goes something like this:
<ul>[*]Mapkey launches a batch file that creates the temp folder[*]Mapkey exports param file to temp folder[*]Mapkey saves a *.ps file to the temp folder[*]Mapkey launches a batch file to process the files[*]Batch file queries parameter file for revision value and stores it in a variable[*]Batch file queries directory for *.ps file name and stores it in avariable[*]Batch file creates an output folder for PDF[*]Batch file calls Distiller to process *.ps file into a *.PDF using <filename>_<rev> format[*]Batch file deletes temp folder and contents and exits
[/list]Since I use distiller and set the final file name with it, I don't use the rename command. I suspect calling up a command prompt and typing 'help rename' would get you on the right path.

The issues I had with multi model drawings was getting the parameters of the right model. The parameter export dialog, if I recall, forces you to pick the model to export from and you have to choose part or assy first. That made a 1 size fits all mapkey challenging, but not impossible. I just recorded it with an assy drawing and recorded an assy pick before the part pick. Since the assy pick isn't available in a part drawing and once you pick 'assy' the dialog goes away, it works just fine.
 
I place the following note just outside the boarder of drawings while in the design stage to ensure that when I'm talking to someone else on the project or a vendor we are on the same page.


<?:namespace prefix = st1 ns = "urn:schemas-microsoft-com:eek:ffice:smarttags" /><st1:place w:st="on"><st1:placeName w:st="on">DRAWING</st1:placeName> <st1:place w:st="on">STATE</st1:place></st1:place>: &PTC_WM_LIFECYCLE_STATE:D &PTC_WM_MODIFIED_ON DRAWING REV-ITERATION: &PTC_WM_VERSION:D MODEL REV-ITERATION:&PTC_WM_VERSION<?:namespace prefix = o ns = "urn:schemas-microsoft-com:eek:ffice:eek:ffice" />
 
Doug. Thanks.
That make the trick.

I changes my script to create pdf to this:


rem ** Sets the path for GSTool.
set gs=P:\software\ghostsc\gs8.54
set path=%gs%\bin;%gs%\lib;%gs%\fonts;%path%
set GS_LIB=%gs%\lib

rem ** Get the plot file name, location & revision **
set INNAME=%1
FOR /F "tokens=3 delims=," %%G IN ('find "PROI_REVISION"
%PTCDRIVE%ptc/pdf/param_table.csv') DO set REVISION=%%G
set OUTNAME=%INNAME:.plt=%~%REVISION%.pdf
rem ** delete old pdf of same drawing in same folder **
del /q %INNAME:.plt=%*pdf
rem ** check for parameter file **
if not exist %PTCDRIVE%ptc/pdf/param_table.csv goto
noparmfile
:: ECHO inname=%INNAME%
:: ECHO REVISION=%REVISION%
:: ECHO OUTNAME=%OUTNAME%

rem ** Start Ghostscript
call %GS_LIB%\ps2pdf14.bat %INNAME% %OUTNAME%

rem ** Delete files.
del /q %INNAME%
del /q %PTCDRIVE%ptc\pdf\param_table.csv
del /q %INNAME:.plt=%-pdf-error.txt
goto :EOF
:noparmfile
del /q %INNAME%
Echo Parameter file: %PTCDRIVE%ptc\pdf\param_table.csv
are missing. Use always mapkey pp to create pdf.
>%INNAME:.plt=%-pdf-error.txt

%PTCDRIVE% are set in the start script for ProE
 

Sponsor

Articles From 3DCAD World

Back
Top