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

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

de re Mapkeys

21-Topaz I

de re Mapkeys

Generally, this document is about Mapkeys, and not a place to collect mapkeys. I think the place to collect mapkeys is a Mapkey Index document and separate documents for each mapkey/mapkey group. For example, the rather lengthy mapkeys should get their own documents, but one liners that do pan-zoom-rotate, for example, can get their own.


Personal Preference


Generally, I recommending storing mapkeys in .txt files and at worst, have only one mapkey in to open the import config dialog to get to them. This way the stays unedited except as required and contains config options. The mapkeys can be maintained with Notepad, or other editor without trouble.


I also recommend that the mapkey window be kept open so that the mapkeys can be selected and Run from the mapkey window. This has the advantage that the names don't step on each other and the names can be both significant and the user can see the description as required.




When any text that is not directed to a dialog box is typed from the keyboard, Creo continuously tries to match the characters to mapkeys. As soon as it sees any match it runs the related stored commands. This means that the user can't have keyboard access to both "X" and "XZ" because as soon as the "X" matches it executes the "X" commands and so "XZ" is never usable. Worse, typing "XZ" will run the "X" command, but leave the "Z", which may not match anything and Creo can't run a mapkey until the "Z" is removed with backspacing.


As mentioned above, they can be selected from the Mapkey dialog box and Run.


Handy config options

- new_parameter_ui no.yes

- cmdmgr_trail_output yes

- display_mapkeys_dialog_on_top yes (creo 3?)


Start with Olaf Corten's suggestion (from use of "main_dlg_cur" command for mapkeys -- from Wildfire5.0 to Creo1.0)


Use this option: cmdmgr_trail_output YES  (before starting recording)


Your ProE trail file then consists mostly of commands like these

    ~ Command `ProCmdModelOpen`

instead of

    ~ Activate `main_dlg_cur` `File.psh_open`


Further Olaf smarts (use of "main_dlg_cur" command for mapkeys -- from Wildfire5.0 to Creo1.0)


  1. Open the with a text editorset the config option cmdmgr_trail_output YES and save the
  2. (re)start ProE
  3. find all mapkeys with "main_dlg_cur" commands (e.g. ~ Activate `main_dlg_cur` `File.psh_open` )
  4. Update them manually: perform the same mapkey step(s) in ProE
  5. open your trail file with a text editor
  6. look at the latest added lines at the bottom (e.g. ~ Command `ProCmdModelOpen` )
  7. Replace the "main_dlg_cur" commands with the "~ Command" commands in the
  8. And while you're at it: remove all ~Select - ~ Close combinations. They're not needed.
  9. Save the Or Re-Record them:


Open the Mapkey dialogue

Pre-Creo1: Tools-> Mapkeys-> [select mapkey]-> Modify-> Record

Creo1: File-> Options-> Environment-> Mapkeys Settings-> [select mapkey]-> Modify-> Record


Now perform the same mapkey step(s) in ProEStop the recording and save.

(Note when re-recording them you will get duplicate mapkeys in your The last one will be the newest.)


This is a spreadsheet that is said to have a bunch of mapkeys in it from Mike Foster- I have not checked them recently enough to remember, but I must have looked at them at one time.

(use of "main_dlg_cur" command for mapkeys -- from Wildfire5.0 to Creo1.0)


From    Mapkey help


That should work. A couple of best practices I have learned while working with mapkeys:

1. Whenever possible avoid clicking icons or using context menus if you can use the menus along the top to achieve the same results. If these mapkeys are going to be used by more  people than yourself, not everyone will have the same icons but the menus along the top will remain the same. Also context menus change sometimes for prt vs asm vs drw.

2. Don't rely on the default options for dialog boxes. Pro/E remembers and saves the last picked options. So if when you record the mapkey the "Solid Models" drop down is selected by default the mapkey won't record that you specifically want that. So if the option changes in the future because you have run another find query and then you run the mapkey, your mapkey will fail.

3. If you can type in the name of the options you want into the drop down boxes. Sometimes you can sometimes you can't. If you don't type it in, Pro/E will often simply record the number from the top of the drop down you picked. The number of items in the drop down can change and then your mapkey will break.

4. When saving to file locations just type the full path in. IE: C:\temp\myfile.prt. Everyone can have different working directories and if you don't type the absolute path it might not work if you change your working directory.

5. If you edit the files by hand you can use the following characters:

!                        This comments out the line (ed. this only works between mapkeys; the command flow inside mapkeys won't work if interrupted)
%                      You can use this to call another mapkey. IE %aa;
\                        This has to be at the end of every line except for the last to indicate the mapkey continues
@SYSTEM         Use this followed by a path to call a script. IE @SYSTEMC:\temp\myscript.bat
\                         If you have a really long (>95 characters) file path you can break it up with the \ character without a ; IE:

mapkey(continued) @SYSTEMC:\really\long\file\path\mysc
mapkey(continued) ript.bat;

That's all I can think of for now.




Advanced Mapkeys

One feature that has been mentioned as handy is that bad commands in mapkeys are simply rejected. So one can build a mapkey that works on parts and fix into it parts that work on assemblies and the command interpreter will ignore the part that doesn't apply. SeeStrategies to implement multi mode mapkey functionality


A hint to making a more universal mapkey: Re: Mapkey difficulty with Creo UI across modes

from Jose Costa

In selecting the results from the Find tool, to select all of them, it may be useful to replace what looks like the list item with a universal reference:


Replace the line

mapkey(continued) ~ Select `selspecdlg0` `ResultList` 1 `7:52:`


mapkey(continued) ~ Select `selspecdlg0` `ResultList` -1; \


Mapkeys for selection filters


See Useful mapkey for changing the selection filter


Mapkey Cautions


Re: Mapkey best practices in Creo


When mapkeys from older versions are still functioning in later versions, it usually means that there was no change in this area.

However, in some rare cases they trigger a mechanism, that loads small parts of the old user interface, to enable the mapkey successfully processing.

These parts of the old UI will usually persist in a session and can alter the UI for this function even when the user is manually selecting menus.


Mapkey Editing


Mapkeys are actually run-on sentences of commands. They are individually line-length limited. The line-continuation character is "\" which will be present on every line except the last line. The missing "\" is how the mapkey processor knows it has reached the end. If, in editing a mapkey, a "\" is removed that should not be, upon importing the mapkey one will typically be rewarded by a long string of stop signs.


Mapkey import error handling is basic. It won't point out errors, it just fails to import completely or anything at all, depending on the type of error.


As a result it is best to create complex mapkeys a small amount at a time and understand how each part works before joining them.


The total length of a mapkey is 65,000+ characters.


Another feature, mentioned by Paul Sobejko, in Re: Copy parameter in Mapkey won't work after re-booting Creo, the "mapkey(continued)" portion is not required; the line continuation character is enough.


Mapkey lines can be divided after any ";' (semicolon) so that it makes reading/editing mapkeys a lot easier. Just add the "/" continuation character at the end of each line except the last line of each mapkey.



Pushing mapkeys to the command ribbon


sharing custom icons in the Creo 2.0 ribbon


Mapkey Writing/Editing Tips by lhoogeveen



Quickly Update Mapkeys in the Current Creo Session (I recommend not storing mapkeys in the, but instead in separate .txt files)

Execute Multiple Mapkeys in one Mapkey

Getting Input from Users

Removing Duplicate Code from Mapkeys

OS Script or executing system CMD lines

Creating mapkeys from Trail Files


Mapkeys and VBA


A powerful use of mapkeys is in combination with VBA. I've had good luck with Excel VBA because it is easy to use Excel to manage large quantities of data, do some data manipulation, and create lists that are accessible to VBA for creating repetitious actions, such as opening all the drawings in a list of names and exporting them.


Mainly it is a matter of creating a file using VBA and then using PRINT #x, "abcdefghijklmnop" where"x" is the file handle from the OPEN command and "abcdefghijklmnop" is each line from the recorded mapkey. To make the mapkey adaptable it is necessary to replace the affected part with a variable.


One thing to watch for is that every line needs a "/" suffix, except the last, but in processing a list one may not know ahead of time when that will occur, particularly if using a FOR EACH loop. I create an initialization section that is missing the "/" from its last line and then the main loop adds the "/" and carriage return (newline/crlf) character at the top, so that when the loop ends, it ends without putting the "/" after the last line. This is useful when the segments of the mapkey have variable contents, such as the different handling that parts and assemblies can require. 

This thread is inactive and closed by the PTC Community Management Team. If you would like to provide a reply and re-open this thread, please notify the moderator and reference the thread. You may also use "Start a topic" button to ask a new question. Please be sure to include what version of the PTC product you are using so another community member knowledgeable about your version may be able to assist.

David, this is a great post! I'm curious about the mapkeys and VBA you mentioned as it could be great combo indeed by being able to use logic and variables. Could you possibly share a simple example of combining mapkeys and VBA to help show what you're talking about either here or in another post? Maybe show connecting to the Creo session and passing in a variable into the mapkey section? I setup the VB API in Creo but haven't done much with it as I was able to get quite a bit done with mapkeys using the methods I shared in my post. However, mapkeys do have their limits and being able to have variables, for loops, and if then logic would be great to add on to mapkeys!

I use VBA to generate a mapkey file, similar to creating a mapkey file by going through the steps and saving the mapkey. As far as Creo is concerned, it doesn't matter how the file is created when it is time to run it. This is separate from using the VB API to interact with Creo; mapkeys are one-way communication.

Loops, et all, get unrolled by the VBA program to create a linear mapkey; Print statements are used to record the results of the path the VBA program took.

I got re-interested in mapkeys and VBA as I have a bunch of assemblies that are being incrementally altered to use replacement parts, but the parts already exist so the Save-As trick doesn't work well to rename subcomponents, the old parts have to retain their current names, and not all the assemblies can be worked on at the same time. So I needed a way to identify all the parts that needed to be renamed, determine the correct replacement names, and then actually use a non-Windchill process to get the correct names in place in the assemblies and related drawings. Excel gave me a convenient scratch-pad for the first two steps, and VBA was used to generate mapkeys to do the third step.

I like your page - it's concise and well written. I was looking to create a general collection to make it easier to find the right info and skip dead ends, and yours is a very helpful addition.

Top Tags