cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

Using Parameter for Filename in Distributed Batch PDF Export

HiperScan
5-Regular Member

Using Parameter for Filename in Distributed Batch PDF Export

Hi,

 

I´m in the middle of generating PDF files of drawings. The drw files have a number as a name. When generating PDFs in the batch process I would like to append the value of a model parameter to the PDF filename for instance: 12345_ExamplePart.pdf where the orange part is the name of the drw-file and the green part represents the value of the parameter.

 

Is this possible?

 

Thanks in advance 

7 REPLIES 7

Hi,

 

I do not believe that Distributed Batch can be configured to follow your wish.


Martin Hanák

As Martin stated, distributed batch cannot do this out-of-the box.

 

However, I believe there are several methods to get this done.

 

1.  You can rename the files after the PDF's have been created.  If you have Windchill, you can easily generate a list (table) that shows the filename & parameter values (assuming the parameter is designated).  You can then export that list (table) to a .txt or .csv file for use in a simple OS script to rename the files.  This is probably the easiest method.

 

2.  If you don't have Windchill or the parameter is not designated for Windchill to see it, you may still be able to extract the filename/parameter values to a file.  Distributed batch will allow you to run a task called "Run a mapkey defined in a config.pro".  If the mapkey exports the parameters to a .txt file, the exported filename is in the format of drawingfilename_par.txt.  I'm assuming the parameter you want is a drawing parameter.  If so, the mapkey isn't that complicated.  In the Parameters dialog, FILE > EXPORT > IN .TXT FORMAT.  If you want to export a model parameter, things get more complicated, but I believe still possible.  You can now extract the parameter from the drawingfilename_par.txt files to generate your rename .txt or .csv file.

 

3.  Distributed batch can also run a task called "ModelCheck".  If you setup modelcheck to just report the parameter value you want, you now have report files, in the mc_reports area, with the filename and parameter.  You can then use those files to generate your rename .txt or .csv file.

 

In methods 2 & 3 above, you can use the same object list in Distributed batch to export the PDF files and run the other modelcheck or mapkey task.

 

Regards,

Dan N.

I'm not at all familiar with Distributed Batch, but I use mapkeys and batch files to append the contents of our REV parameter to exported files.  It involves exporting a text file of parameters and values, reading that file to extract the contents of the REV parameter and then renaming the output file to include the REV parameter.

 

As Dan mentioned, the trick is getting model parameters exported from a drawing.  You have to take into account parts vs. assemblies and multimodel drawings.  It's a bit tricky, but doable.  Once you get mapkeys and batch files set up to do the work, there may be a way to integrate that into Distributed Batch.

--
Doug Schaefer | Experienced Mechanical Design Engineer
LinkedIn
HiperScan
5-Regular Member
(To:dgschaefer)

Thank you Doug and Dan. Can you recommend any tutorials or documents I should read for working out a solution with Batch Scripts and mapkeys?

 

 

sparulekar
14-Alexandrite
(To:dgschaefer)

Can you please tell me how you use mapkeys and batch files to append the contents of REV parameter to exported file?


@sparulekar wrote:

Can you please tell me how you use mapkeys and batch files to append the contents of REV parameter to exported file?


I'm no longer in the Creo world and don't have the files handy anymore, but I can give you the top level gist of it. I used a series of nested mapkeys to do all the work.  One mapkey calls a batch file and then another series of mapkeys and at the end it calls another batch file.

 

  1. A mapkey calls a batch file that creates a temporary folder somewhere for exporting the files.
  2. It then exports all parameter information to a file in that folder.
  3. It then exports the part / assy / drawing in the desired format to that folder.
  4. It then calls another batch file that processes the file.
  5. The batch file searches the parameter file for the parameter name. 
  6. It saves the line with the parameter to another text file.
  7. It parses that file for the parameter value and sets it to a variable.
  8. It then looks for the exported file and captures the file name.
  9. It then renames the exported file with the parameter value at the end.
  10. It moves that file to a new folder names with the current date and the file type (ie 190303_PDF)
  11. It then deletes the temporary folder and all the files used for processing.

I think that's how it was done, as I've said I've been away from it for some time. If you search here, I'm pretty sure that I described the process in more detail, including some code snippets, somewhere.  Others have done similar things and have published their methods as well.

 

Good luck.

--
Doug Schaefer | Experienced Mechanical Design Engineer
LinkedIn
sparulekar
14-Alexandrite
(To:dgschaefer)

Thank you so much. I will try it out

Announcements
NEW Creo+ Topics: Real-time Collaboration


Top Tags