I'm new to Creo I've been trying to figure our how to rename files when using Creo Distributed Batch 184.108.40.206
The files have part numbers with a "ABC-00-1234" format but the file names for exported PDF's and STEP files come out as "abc-00-1234".
Is there a ToolKit command I can use to:
1. Make the first 3 letters in the part number capital.
2. Add "_rev" and the file revision parameter of the end of the file name.
In the end, I want the file names to be displayed as "ABC-00-1234_revA".
Both is possible, but you need to programm it down in C / C++,
use another solution (Not distributed batch) on the marked like CREOSON,
or a third party product like GENIUS TOOLS Model Processor or IT-Link Publish Documents.
So you need to decide it the effort and the invest to the TOOLKIT license is worth it. You can also use the free version of the JAVA Interface as a synchronous application (I have never done that, but afaik it should be possible too).
You can make the changes post batch via a CMD/DOS script or Powershell script. AutoIT is another option (and it's free).
The case switch should be simple enough (AutoIT-StringUpper; Powershell-ToUpper), and the revision information is stored within the header of the Creo Parametric files from which you can extract the necessary information (I'm assuming you're using Windchill).
But in case he is using WT he can't use AutoIT (thought on powershell first) because he didn't get the .prt/.asm file except he make a backup copy inside a temp directory, which could need a hugh amount of time/space on bigger assemblies.
What could be an idea would be to save the parameter list as an .txt file by mapkey and use that information (Parameter -> File -> Export as ...) for the reference. I like the idea.
If the STEP file was exported with all parameters (vs. none or designated), the revision information is in the STEP file under the PTC_WM_REVISION parameter. If the parameter information wasn't exported (or cannot be exported for some reason), there are other methods available to capture the revision information like the mapkey method you mentioned. AutoIT can certainly be used to do the job after all the batch processing is complete if the revision information is captured somehow.
The name of a model in in session always in upper case, and will be written as lower case if you save the model.
Therefore if you have the model name in session you don‘t need to convert the name if only the first three characters needs to be converted to upper/lower case.
For the revision parameter you need to check if the parameter exist, as well a common folder for saving the output may need to be created.
extern ProError ProIntf3DFileWrite (
#define PRO_PATH_SIZE 260
For the Output, you can specify the complete path of the file (output_file).
I use a Tcl Toolkit interface, where you can export a model by specifying the export type and the full path as you would expect.
Here the small and complete code for export the STEP with all defaults and a lot of notes, code is 4 lines
I would write mode lines of code, for debug purpose
# Assume you have an active Assembly
# If the paramete PTC_WM_REVISION not exists, an error would be raised
# This can be check with 'set paramExist [ps_param exists PTC_WM_REVISION]'
# The code here does not check for exists
# First get your requested output name
# Within the one line:
# 'file root FooBar.asm ' will return 'FooBar' (get rid of the extension)
# 'ps_param value PTC_WM_REVISION' will return the value of PTC_WM_REVISION for the current model
# For the assembly ABC-00-1234.ASM and if PTC_WM_REVISION contains B
# It will set the var filename to 'ABC-00-1234_rev_B.stp'
set filename [format "%s_rev_%s.stp" [file root [ps_model current]] [ps_param value PTC_WM_REVISION] ]
# Create a saveasObj, ps_saveas implements ProIntf3Dexport.h
# Now configure it, if you don't specify a folder like c:/temp, the current working folder is used
saveAsObj -type step -assyconf single -out [file join c:/temp $filename]
# Now Save/Export to disk