I've created several mapkeys lately so I thought I'd share some general tips I learned to write it down for next time. Please share your own tips below to expand the collection.
This was done on Creo 3 M060 but the ideas should hopefully be not specific to that.
Mapkey Writing/Editing Tips
General Tips:
Quickly Update Mapkeys in the Current Creo Session
THIS WAS MY BIGGEST DISCOVERY FOR MAPKEYS TESTING! Originally, I would update the config.pro text file and close Creo to update my mapkeys. However, you can just reimport the newly saved config.pro from within Creo so you don’t destroy your test setup. I wrote a mapkey to do that called UPMAP that uses my working directing config.pro. My working directory is in the C:\Users\Public\Documents location. Hopefully this works for you but I make no promises. Make sure to save your work before trying any new mapkeys.
mapkey upmap @MAPKEY_LABELUpdate Config.Pro - upmap;\
mapkey(continued) ~ Command `ProCmdRibbonOptionsDlg`;\
mapkey(continued) ~ Select `ribbon_options_dialog` `PageSwitcherPageList` 1 `ConfigLayout`;\
mapkey(continued) ~ Select `ribbon_options_dialog` `ConfigLayout.ImportExportBtn`;\
mapkey(continued) ~ Close `ribbon_options_dialog` `ConfigLayout.ImportExportBtn`;\
mapkey(continued) ~ Activate `ribbon_options_dialog` `ConfigLayout.Open`;\
mapkey(continued) ~ Trail `UI Desktop` `UI Desktop` `DLG_PREVIEW_POST` `file_open`;\
mapkey(continued) ~ Activate `file_open` `Current Dir`;\
mapkey(continued) ~ Select `file_open` `Ph_list.Filelist` 1 `config.pro`;\
mapkey(continued) ~ Command `ProFileSelPushOpen_Standard@context_dlg_open_cmd`;\
mapkey(continued) ~ Activate `ribbon_options_dialog` `OkPshBtn`;
Execute Multiple Mapkeys in one Mapkey:
I’ve only done this once so bear with me here with some help from James post linked below. This example calls >storetmp then >partnamesave followed by >loadconf mapkeys. Note the ~ is not required.
mapkey(continued) %>storetmpfile;%>partnamesave;%>loadconf;\
mapkey(continued) ~ Activate `ribbon_options_dialog` `CancelPshBtn`;\
How to create a drawing with same name as active model with Mapkeys
Getting Input from Users
Sometimes you need to get input from users before continuing. You can change how the mapkey records input, but I haven’t played with this too much.
I usually just leave it at the default and add code in as needed. The two commands I know about are @MANUAL_PAUSE and @PAUSE_FOR_SCREEN_PICK. @MANUAL_PAUSE lets you tell users what they’re supposed to do but make sure you tell them to RESUME and not click any Creo menus as needed. Sometimes you need a @MANUAL_PAUSE with @PAUSE_FOR_ SCREEN_PICK.
mapkey(continued) ~ Activate `visual_dlg0` `Edit`;@MANUAL_PAUSESelect primary surface. RESUME;\
mapkey(continued) @MANUAL_PAUSESelect the bottom edge or surface. RESUME;@PAUSE_FOR_SCREEN_PICK;\
Removing Duplicate Code from Mapkeys:
When inputting keyboard values, Mapkeys can create many extra lines which can make it tedious to edit later. Remove if possible but test as you go as some items cannot be simplified.
mapkey(continued) ~ Activate `visual_dlg0` `ZoneNmCreate`;\
mapkey(continued) ~ Input `visual_dlg0` `Table_INPUT` `v`;\
mapkey(continued) ~ Input `visual_dlg0` `Table_INPUT` `vi`;\
mapkey(continued) ~ Input `visual_dlg0` `Table_INPUT` `vie`;\
mapkey(continued) ~ Input `visual_dlg0` `Table_INPUT` `view`;\
mapkey(continued) ~ Input `visual_dlg0` `Table_INPUT` `view4`;\
mapkey(continued) ~ Input `visual_dlg0` `Table_INPUT` `view4d`;\
mapkey(continued) ~ Input `visual_dlg0` `Table_INPUT` `view4dx`;\
mapkey(continued) ~ Input `visual_dlg0` `Table_INPUT` `view4dxf`;\
mapkey(continued) ~ Update `visual_dlg0` `Table_INPUT` `view4dxf`;\
mapkey(continued) ~ Activate `visual_dlg0` `Table_INPUT`;\
The RMB menu commands open and closes before executing. Remove these lines and go straight to the command.
mapkey(continued) ~ Timer `UI Desktop` `UI Desktop` `popupMenuRMBTimerCB`;\
mapkey(continued) ~ Close `rmb_popup` `PopupMenu`;\
mapkey(continued) ~ Command `ProCmdDwgPageSetup@PopupMenuGraphicWinStack`;\
In general, the ARM and DISARM commands when paired next to each other do nothing:
mapkey(continued) ~ Arm `relation_dlg` `ParamsPHLay.ParTable` 2 `rowCUBE` `name`;\
mapkey(continued) ~ Disarm `relation_dlg` `ParamsPHLay.ParTable` 2 `rowCUBE` `name`;\
mapkey(continued) ~ Select `relation_dlg` `ParamsPHLay.ParTable` 2 `rowCUBE` `name`;\
In general, the OPEN and CLOSE commands when paired next to each other do nothing:
mapkey(continued) ~ Open `main_dlg_cur` `LayerActionMenu`;\
mapkey(continued) ~ Close `main_dlg_cur` `LayerActionMenu`;\
mapkey(continued) ~ Command `ProCmdLayer_SelectLayers`;\
When selecting items sometimes additional lines get added. Here’s an example where I select a parameter and designate it to Windchill:
mapkey(continued) ~ Select `relation_dlg` `ParamsPHLay.ParTable` 2 `rowDESCP` `value`;\
mapkey(continued) ~ RButtonArm `relation_dlg` `ParamsPHLay.ParTable` 2 `rowDESCP` `value`;\
mapkey(continued) ~ PopupOver `relation_dlg` `ParamsPHLay.ParamUtils` 1 `ParamsPHLay.ParTable`;\
mapkey(continued) ~ Activate `relation_dlg` `ParamsPHLay.PBUtilDesignate`;\
OS Script or executing system CMD lines
I have limited experience with using this. The final mapkey code can become hard to read as it needs \n between CMD line commands – try to space it out to multiple make it legible. James has a good example here:
How to create a drawing with same name as active model with Mapkeys
I haven’t found the ability to toggle @SYSTEM with regular mapkey commands (I’m sure it’s possible). For now, I just call it at the end of the mapkey or create a separate mapkey just to do @system commands like in James’ example.
Creating mapkeys from Trail Files
You can also copy Creo mapkey code from trail files but keep in mind there will be a lot of trail file code you don’t want in a mapkey. I would only do this once you know how to read and write mapkeys. I strongly recommend sticking with the normal mapkey method I described above in the General Tips for most cases. Here’s an example:
Re: Can a mapkey delete itself?
If you have some additional tips, please share below.
One thing that helps me remember what key string triggers a particular mapkey is to put it in brackets in the Name field; In config.pro, it will look something like this:
mapkey dd @MAPKEY_LABELSketch Dimension (dd);\
~ Command `ProCmdSketDimension` 1;
Months later I type in "dimension" into the search bar in the upper right corner of the ribbon, and a list shows up - and one of the items is "Sketch Dimension (dd)" - so then I remember that dd is the shortcut...
Hi Lucas,
Thank you for all your mapkey tips!
If you want to avoid the mapkey window behind other windows you can use this config option:
display_mapkeys_dialog_on_top yes
Albert,
Great tip! I eventually wrote a mapkey to get around that opens the mapkeys and will bring it to the top. It will exit out if you are currently recording a mapkey though... but I liked that better than not being able to find the mapkey window. Remove the last two rows if you don't like that feature.
mapkey map @MAPKEY_NAMEOpens Mapkey menu to display mapkeys in current session.;\
mapkey(continued) @MAPKEY_LABELOpen Mapkeys (map);\
mapkey(continued) ~ Command `ProCmdUtilMacros`;\
mapkey(continued) ~ Activate `mapkey_main` `NewButton`;\
mapkey(continued) ~ Activate `mapkey_record` `CancelButton`;
Enjoy!
Luke
Use the config option "cmdmgr_trail_output yes" to eliminate most of the extra lines from your mapkeys.
Moving this blog to the Creo area to give it exposure.
Best,
Toby
To your question about character limit per line. Unless it has changed in recent years, it has always been 80.
It does ignore "mapkey(continued)" in that count.
Therefore, I have always had these lines in my config.pro files... and drag my notepad window width to touch the end of the line as a visual reference.
!=================================================
!2345678901234567890123456789012345678901234567890123456789012345678901234567890
!=================================================
!mapkey(continued)12345678901234567890123456789012345678901234567890123456789012345678901234567890
!=================================================
I have found a way to put a comment line in the middle of a multi-line mapkey.
It still gets parsed but gets ignored since plain text is not a command.
However, if you put a %.. in the line somewhere the mapkey will probably break.
The line of text just has to have a back-slash at the end.
Ex...
mapkey vr @MAPKEY_LABELView Right;~ Command `ProCmdViewNamePick` 1 \
! testing a comment line in the middle of a mapkey \
mapkey(continued) ~ Select `nameviewlist` `nv_list`1 `RIGHT`;
Don Rutledge These are both great tips! I just tested to comment line and it works! Not required but I might propose starting mapkey comment lines with mapkey(continued) so it's obvious that it's part of the same mapkey. I like using the ! to imply it's a comment but it's not required either.
mapkey(continued) ~ Activate `drawing_view` `psh_apply`;\
mapkey(continued) !Useful for long mapkeys or fancy logic\
mapkey(continued) ~ Select `drawing_view` `options_list` 1 `ViewDisp`;\
These are all great inline Comment hacks. I use a custom Notepad++ language that color codes the text and have tested that this hack works as well:
Example shown in a working mapkey:
Hi Lucas,
could you help me solving this problem?:
How to record Check-out OK Button for mapkey?
Thanks
Comment lines start with ! and do not have to be at the beginning or the end of the file.
happy commenting.
! I am a comment line
Also, I have blank lines in my current config.pro file. One time when I was troubleshooting a problem Creo support told me to remove the blank lines but that was just a bug in that release. Since then I think it has been fixed again.
When my mapkey window dissapears behind the other Creo windows, I simply minimizes and maximizes creo in Windows, by clicking on the windows toolbar twice 🙂
regards Torkil
Here's a way of writing a helpful text message to the end-user by displaying
multiple lines of text in the PAUSE dialog box, by using the newline code \n :
mapkey xx @MAPKEY_NAMEDemo of multi-line pause;\ mapkey(continued) @MAPKEY_LABELDemo;\ @MANUAL_PAUSEInstructions for end-user:\n\n\ Use the newline character " \\n "\n\ to add lines to your text displayed in\n\ the PAUSE dialog box\n\n\ Like you see in this example.;
Results in:
Looks like the original mapkey discussion around creating/opening a drawing with the same name disappeared at some point. Here are mapkeys for Creo 4 M040 to open drawing with same name (ODRW) and create new drawing with same name (NDRW). ODRW should work with Windchill. You will need to include the mapkeys between the !============ for ODRW and NDRW to work. As usual with mapkeys, you will have to test/validate with your specific build of Creo.
mapkey odrw @MAPKEY_NAMEOpen drawing with same name as active model or selected assembly part;\
mapkey(continued) @MAPKEY_LABELOpen Drawing w/ Same Name (odrw);\
mapkey(continued) ~ Command `ProCmdOpenModel@PopupMenuGraphicWinStack`;\
mapkey(continued) ~ Activate `open_instance` `open`;\
mapkey(continued) %>storetmpfile;%>partnameopen;%>loadconf;\
mapkey(continued) ~ Command `ProCmdModelOpen`;\
mapkey(continued) ~ Activate `file_open` `workspace_pb`;\
mapkey(continued) %partnameopen;\
mapkey(continued) ~ Activate `file_open` `Inputname`;
mapkey ndrw @MAPKEY_LABELNew Drawing w/ Same Name (ndrw);\
mapkey(continued) %>storetmpfile;%>partnamenew;%>loadconf;\
mapkey(continued) ~ Command `ProCmdModelNew`;\
mapkey(continued) ~ Select `new` `Type` 1 `Drawing`;\
mapkey(continued) ~ Activate `new` `chk_use_default_template`0 ;\
mapkey(continued) %partnamenew;\
mapkey(continued) @MANUAL_PAUSEName drawing and Resume.;\
mapkey(continued) ~ Activate `new` `OK`;\
mapkey(continued) ~ Select `dwg_create` `rad_format` 1 `1`;
!======================
mapkey >storetmpfile @MAPKEY_LABELStore model name to temp file;\
mapkey(continued) ~ Command `ProCmdModelSaveAs` ;\
mapkey(continued) #CURRENT VALS;\
mapkey(continued) ~ Activate `storage_conflicts` `Close_PushButton`;\
mapkey(continued) ~ Select `file_saveas` `type_option` 1 `db_129`;\
mapkey(continued) ~ Activate `file_saveas` `check_is_secondary` 0;\
mapkey(continued) ~ Activate `file_saveas` `Current Dir`;\
mapkey(continued) ~ Activate `file_saveas` `OK`;\
mapkey(continued) ~ Activate `UI Message Dialog` `ok`;
mapkey >partnameopen @MAPKEY_LABELGets partname to open drawing;\
mapkey(continued) @SYSTEMdel sw.pro\n\
mapkey(continued) dir /b *.pic>\%temp\%\\filename.txt\n\
mapkey(continued) set /p VAR1=<\%temp\%\\filename.txt\n\
mapkey(continued) del \%temp\%\\filename.txt\n\
mapkey(continued) set FILENAME=\%VAR1:\~0,-4\%\n\
mapkey(continued) echo mapkey partnameopen \~ Update `file_open` \
mapkey(continued) `Inputname` `\%FILENAME\%.drw`\;>>sw.pro\n\
mapkey(continued) del *.pic;
mapkey >partnamenew @MAPKEY_LABELGets partname for new part;\
mapkey(continued) @SYSTEMdel sw.pro\n\
mapkey(continued) dir /b *.pic>\%temp\%\\filename.txt\n\
mapkey(continued) set /p VAR1=<\%temp\%\\filename.txt\n\
mapkey(continued) del \%temp\%\\filename.txt\n\
mapkey(continued) set FILENAME=\%VAR1:\~0,-4\%\n\
mapkey(continued) echo mapkey partnamenew \~ Input `new` \
mapkey(continued) `InputPanel1` `\%FILENAME\%`\;>>sw.pro\n\
mapkey(continued) del *.pic;
mapkey >loadconf @MAPKEY_LABELLoad mapkey into session;\
mapkey(continued) ~ Command `ProCmdRibbonOptionsDlg`;\
mapkey(continued) ~ Select `ribbon_options_dialog` `PageSwitcherPageList` 1 `ConfigLayout`;\
mapkey(continued) ~ Activate `ribbon_options_dialog` `ConfigLayout.Open`;\
mapkey(continued) ~ Activate `file_open` `Current Dir`;\
mapkey(continued) ~ Update `file_open` `Inputname` `sw.pro`;\
mapkey(continued) ~ Command `ProFileSelPushOpen@context_dlg_open_cmd`;\
mapkey(continued) ~ Activate `ribbon_options_dialog` `OkPshBtn`;\
mapkey(continued) ~ Activate `UITools Msg Dialog Future` `no`;\
mapkey(continued) @SYSTEMDel sw.pro;
!======================
Thank you very much for this solution! It's works also with Creo3.
In a mapkey you can call batch commands - which is awesome! They get a little difficult to read/write in Notepad because you have to use a \ to 'break' before any odd characters so I like to create the batch/mapkey text via the Mapkey OS script tab. Then I can save to be able to copy/paste the mapkey appropriate text as needed - even in the middle of a mapkey.
The batch command above results in this code below with the \ added to break/escape as needed. \n or \n\ between lines.
mapkey >partnamedxf @MAPKEY_LABELGets partname for new DXF;\
mapkey(continued) @SYSTEMdel sw.pro\n\
mapkey(continued) dir /b *.pic>\%temp\%\\filename.txt\n\
mapkey(continued) set /p VAR1=<\%temp\%\\filename.txt\n\
mapkey(continued) del \%temp\%\\filename.txt\n\
mapkey(continued) set FILENAME=\%VAR1:\~0,-4\%\n\
mapkey(continued) echo mapkey partnamedxf1 \~ Input `new` \
mapkey(continued) `InputPanel1` `\%FILENAME\%_dxf`\;>>sw.pro\n\
mapkey(continued) echo mapkey partnamedxf2 \~ Input `new` \
mapkey(continued) `InputPanel1` `\%FILENAME\%__dxf`\;>>sw.pro\n\
mapkey(continued) del *.pic;
You can have a batch command in the middle of a mapkey:
mapkey(continued) ~ Activate `UITools Msg Dialog Future` `no`;\
mapkey(continued) @SYSTEMif not exist C:\\Users\\Public\\Documents\\Creo_BOM_Export \
mapkey(continued) md C:\\Users\\Public\\Documents\\Creo_BOM_Export\n\
mapkey(continued) cd C:\\Users\\Public\\Documents\\Creo_BOM_Export\n\
mapkey(continued) del *.bom*\n\
mapkey(continued) del *.csv*\n\
mapkey(continued) cd C:\\Users\\Public\\Documents\n\
mapkey(continued) del *.bom*;\
mapkey(continued) ~ Command `ProCmdInfoBom`;\
After many hours of troubleshooting a few overlapping issues, I just discovered that the commenting feature exclamation mark "!" does NOT work 100%! I.e. Mapkeys that are commented out can break subsequent mapkeys!
If you comment out a mapkey and that comment doesn't have a blank line after it, it can break the mapkey it touches! So now we need to leave empty spaces between mapkeys and their comments in case something in the comment may break what follows! In addition this means we should probably always leave a blank space between mapkeys as well.
How annoying. Examples below:
"
!mapkey breakme @MAPKEY_NAMEName;@MAPKEY_LABELLabel;
mapkey 5test @MAPKEY_NAMEName;@MAPKEY_LABELLabel;\
mapkey(continued) %openops;
"
Although I finally figured it out, I am simultaneously very frustrated and annoyed.
The solution works also with Creo 6 !!!
@ggalli, Thanks for letting us know...Has this ever caused you problems with your config/Mapkeys, or were you only testing for Creo6?
For now I'm testing it with Creo6 because we're going to upgrade from Windchill 10 & Creo 3 to Windchill 11.2 & Creo 6. At the moment it seems that everthing is working properly.