Skip to main content
14-Alexandrite
April 7, 2025
Question

Making a mapkey, Anyway to copy the name of the file currently up on the screen?

  • April 7, 2025
  • 5 replies
  • 1409 views

Hi Guys,

 

Im trying to make a mapkey that makes a new file...with the same name that is currently up on the screen just with a -MFG at the end. 

 

Example. Current file on screen. called N12345-1234.prt

I want to make a mapkey that will create a NEW part file. Called N12345-1234-MFG.prt. (or what ever the original part name is on the screen with a -MFG added to it)

 

Is there any place i can copy the current name from? 

 

I tried in a few areas, with a copy / paste but the mapkey just copies the text..so the files are always called the same thing. (No good)  They all come out as N12345-1234-mfg.prt no matter what the original file is called. 

 

Is there a way to use parameters when naming a file? Or anyone know of any other way to grab the current file name?

 

Thanks,

Jay

5 replies

22-Sapphire II
April 7, 2025

AFAIK this cannot be done using Creo functionality. It is possible using a combination of mapkeys and one or more external scripts or batch files to rename the newly created part.

 

This will generate the desired string in Creo in the active source model where you add the -mfg suffix.

 

To set a parameter equal to the name of the model, type the following:   

Part_Name=rel_model_name 

Where "Part_Name" is the name of the parameter you want equal to the model name.

 

See this previous thread for a working method of how to implement this.

https://community.ptc.com/t5/3D-Part-Assembly-Design/Use-a-parameter-value-in-a-file-name/td-p/144791 

15-Moonstone
April 7, 2025

It can be done by a combination of a macro and a script, as tbraxton wrote

the cons: if your system language is not English by default, the script should be more complex
so,

rename the attached file to mfg.vbs
Put it in a folder c:\ptc\creo for example

Add to the config.pro new mapkey to call the script

 

mapkey mfg @SYSTEMstart WScript.exe \
mapkey(continued) \\ptc\\creo\\mfg.vbs;

 

open current model and call the mapkey

24-Ruby III
April 8, 2025

@Van_AG wrote:

It can be done by a combination of a macro and a script, as tbraxton wrote

the cons: if your system language is not English by default, the script should be more complex
so,

rename the attached file to mfg.vbs
Put it in a folder c:\ptc\creo for example

Add to the config.pro new mapkey to call the script

 

mapkey mfg @SYSTEMstart WScript.exe \
mapkey(continued) \\ptc\\creo\\mfg.vbs;

 

open current model and call the mapkey


Hi,

thank you for uploading mfg.txt. I added some comments during testing.

' https://community.ptc.com/t5/3D-Part-Assembly-Design/Making-a-mapkey-Anyway-to-copy-the-name-of-the-file-currently-up/m-p/1009271
Dim WshShell

' Creo mapkey
' mapkey mfg @SYSTEMstart WScript.exe \
' mapkey(continued) E:\\tmp\\mfg.vbs;

' https://ss64.com/vb/shell.html
set WshShell = WScript.CreateObject("WScript.Shell")

' https://ss64.com/vb/sendkeys.html
' For SHIFT prefix with +
' For CTRL prefix with ^
' For ALT prefix with %

' %f = ALT+F ... File
' f = F ....... Manage File
' r = R ....... Rename
WshShell.SendKeys "%ffr"
WScript.Sleep 50

' ^c = CTRL+C ... copies file name displayed in "New file name" field
WshShell.SendKeys "^c"
WScript.Sleep 50

' {ESC} ... closes "Rename" dialog box
WshShell.SendKeys "{ESC}"
WScript.Sleep 50

' ^n = CTRL+N ... opens "New" dialog box ... "File name" is active ... default file name is selected
WshShell.SendKeys "^n"
WScript.Sleep 50

' ^v = CTRL+V ... replaces default file name with name located in clipboard
' -mfg .......... adds "-mfg" string at the end of file name
WshShell.SendKeys "^v-mfg"
WScript.Sleep 50

' {ENTER} ... closes "New" dialog box ... new part is created
WshShell.SendKeys "{ENTER}"

' end of script
WScript.Quit()

 

12-Amethyst
June 9, 2025

Try this to see if it works for you. You still need to "Ctrl+C" the filename, but it might be a little quicker.

I used "zx" as the mapkey. You can change it to what you prefer.

 

mapkey zx @MAPKEY_LABELcreate_mfg_part;~ Close `main_dlg_cur` `appl_casc`;\
mapkey(continued) ~ Command `ProCmdModelSaveAs` ;@MANUAL_PAUSECOPY FILE NAME WITHOUT .PRT\;\
mapkey(continued) \nCLICK RESUME;~ Input `file_saveas` `Inputname` `TEST`;\
mapkey(continued) ~ Input `file_saveas` `Inputname` `TEST-`;\
mapkey(continued) ~ Input `file_saveas` `Inputname` `TEST-M`;\
mapkey(continued) ~ Input `file_saveas` `Inputname` `TEST-MF`;\
mapkey(continued) ~ Input `file_saveas` `Inputname` `TEST-MFG`;\
mapkey(continued) ~ Update `file_saveas` `Inputname` `TEST-MFG`;~ Activate `file_saveas` `OK`;

12-Amethyst
June 9, 2025

I just noticed it used my "TEST" filename. Let me see if I can fix that.

12-Amethyst
June 9, 2025

I couldn't get it to work either. I was  in too much of a hurry to try this and then noticed that you had already tried what I was doing.

12-Amethyst
March 1, 2026

Hi Jay,

 

I have done this in the past by creating a mapkey that stores model info to a file, initiates a batch file that extracts the filename and creates a trail file. The mapkey follows by running the trailfile.

 

I updated this for Creo 11, attached is the mapkey and the batch file. Save the batch file in C:\temp and read the mapkey in session and it should work. The trailfile is also created in C:\temp.

 

best regards, 

Patrick Brulot