Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X
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
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.
Hi,
it's possible, but it's not easy.
Please read following discussions.
https://community.ptc.com/t5/3D-Part-Assembly-Design/quickly-open-drawing/m-p/603859
https://community.ptc.com/t5/3D-Part-Assembly-Design/Quick-open-drawing-from-part/m-p/928587
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
@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 exampleAdd 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()
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`;
I just noticed it used my "TEST" filename. Let me see if I can fix that.
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.
