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

Community Tip - Help us improve the PTC Community by taking this short Community Survey! X

mapkey fun - manipulate filename of nuetral files

MikeLockwood
22-Sapphire I

mapkey fun - manipulate filename of nuetral files

We've been asked to refine existing mapkeys if possible for creating neutral files (e.g. STEP) in order to manage the resulting filename..

 

Ideal would be to automatically add the date and maybe other info.

 

Example

Creo Parametric file 12345.PRT (in Windchill as CAD Document 12345.PRT X1.4)

Save As STEP

>> resulting file by default is 12345.STP

>> would like resulting file to be 12345_03-30-17.STP

>> really great would be 12345_X1_4_03-30-17.STP

 

Any thoughts on doing this?

 

note: We're also pursuing thru WVS publishing.

 

thanks in advance

4 REPLIES 4
Chris3
20-Turquoise
(To:MikeLockwood)

You have a mapkey that saves the parameters (including the Windchill parameters) to a text file. Then you save the step file. Then the mapkey calls a batch or visual basic script which reads the parameter text file and performs a rename on the step file.

Windchill 10.1 and beyond can publish step files for you but that capability does not allow for customization of filenames. If you want that as part of the publishing you will need to develop it yourself or contact a 3rd party.

dnordin
15-Moonstone
(To:MikeLockwood)

Mike,

Since you only need the date and version information, you can save the "File History" to a file (modiflist.inf).  The 4th and 5th lines are always the model name and version/state information.  For example:

  MODEL: 64639_904056_CONNECTOR
  VERSION: 0.1 In Work
 
If you include a model save before you save the file history (if doing this outside of WVS), you can even pull the date and time when the file was last saved from the modiflist.inf file as well.  This would record the date of the last model modification, not the date when the step file was created (if this is of importance).  If you need additional parameter information, saving the parameters to a .csv or .txt file is the way to go.

If you use powershell scripting or AutoIT, you can pull the model name and version information from the Creo Parametric model window title as well although you need to make sure you have the correct Creo Parametric window active when retrieving this information.  This method would not work via WVS publishing since Creo Parametric runs with "/nographics".

We already do something very similar using AutoIT and mapkeys, but we haven't looked at doing this via WVS publishing.  We have a menu item for the users to generate the data in an active Creo Parametric session.

A question for you:
OOTB can WVS run a custom script/command during publication?  I haven't investigated this.

Regards,

Dan N.

TomU
23-Emerald IV
(To:dnordin)

Daniel Nordin wrote:
OOTB can WVS run a custom script/command during publication?

This is possible with a small customization.  PTC provides examples in these two articles:

We use a batch file for things like this.

To get the current date in a batch file use this:

date /t > fulldate.txt

for /F "tokens=2 delims= " %%i in (fulldate.txt) do set config_today=%%i

set config_today > date.txt

for /F "tokens=2 delims=/=" %%i in (date.txt) do set MONTH=%%~i

for /F "tokens=3 delims=/=" %%i in (date.txt) do set DAY=%%~i

for /F "tokens=4 delims=/=" %%i in (date.txt) do set YEAR=%%~i

set config_date=%MONTH%-%DAY%-%YEAR%

del fulldate.txt

del date.txt

That sets the variable "config_date" to MM-DD-YYYY, I believe.  Elsewhere we use this syntax:

SET destination_folder=%YEAR:~-2%%MONTH%%DAY%

That sets "destination_folder" to YYMMDD.

To extract parameter info, we use a mapkey to save the parameter info into a text file and then use this to look for the rev parameter:

findstr "REV" ce_param_temp.txt.1 > rev.txt

for /F "tokens=2 delims= " %%i in (rev.txt) do set REVISION=%%~i

ce_param_temp.txt.1 is the parameter text file, this sets the value of the REV paramter to the "REVISION" variable so that we can use it later to rename the files:

rename %FILENAME%.%type% %FILENAME%_%REVISION%.%type%

This line is set to work with many different file types, we set the "FILENAME" and "TYPE" variables, earlier.

Hopefully that should get you started in writing your own batch files to suit your needs.

--
Doug Schaefer | Experienced Mechanical Design Engineer
LinkedIn
Top Tags