Skip to main content
13-Aquamarine
April 29, 2022
Solved

Mapkey Toggle Grid (HIDE Grid / SHOW Grid)

  • April 29, 2022
  • 1 reply
  • 3681 views

Hey guys, I'm on Creo Parametric 6.0 and I created 2 mapkeys to turn on/off a grid for any .drw files and I would like to know if it's possible to create a toggle in order to have only 1 mapkey for both the actions.

I saw that when you have 1 for on and 0 for off, you could remove the number to create the toggle but here we have #SHOW GRID or #HIDE GRID.

 

The 2 mapkeys are as follows :

 

mapkey(continued) ~ Activate `main_dlg_cur` `page_Sketch_control_btn` 1;\
mapkey(continued) ~ Command `ProCmdDwgDraftGrid` ;#GRID PARAMS;#X&Y SPACING;15;#DONE/RETURN;\
mapkey(continued) #HIDE GRID;~ Command `ProCmdObjActUI` 1;

 

mapkey(continued) ~ Activate `main_dlg_cur` `page_Sketch_control_btn` 1;\
mapkey(continued) ~ Command `ProCmdDwgDraftGrid` ;#GRID PARAMS;#X&Y SPACING;15;#DONE/RETURN;\
mapkey(continued) #SHOW GRID;~ Command `ProCmdObjActUI` 1;

 

Thank you in advance.

Best answer by pausob

As suggested by @tbraxton , you can overload a mapkey with commands from multiple modes and the ones that do not apply to the one active at the call time will be "ignored" (I do believe this requires that you have that config.pro setting mapkeys_execution not changed from the default no_feedback so that they do not throw error messages)

 

The basic idea remains that the mapkey redefines itself when called thereby producing the toggling action.

 

Tested this in Creo 4 - in your on_grid.pro and no_grid.pro files could be changed to:

 

no_grid.pro:

!**** Commands to turn grid off
sketcher_disp_grid no

mapkey $F4 @MAPKEY_LABELGrid Toggle;\
mapkey(continued) ~ Activate `main_dlg_cur` `page_Sketch_control_btn` 1;\
mapkey(continued) ~ Command `ProCmdDwgDraftGrid` ;#GRID PARAMS;#X&Y SPACING;15;#DONE/RETURN;\
mapkey(continued) #HIDE GRID;~ Command `ProCmdObjActUI` 1;\
%.ifcp;\
mapkey(continued) ~ Input `file_open` `Inputname` `D:\\ProE Standards\\Config\\on_grid.pro`;\
mapkey(continued) ~ Command `ProFileSelPushOpen_Standard@context_dlg_open_cmd` ;\
mapkey(continued) ~ Activate `ribbon_options_dialog` `OkPshBtn`;

 

on_grid.pro:

!**** Commands to turn grid on
sketcher_disp_grid yes

mapkey $F4 @MAPKEY_LABELGrid Toggle;\
mapkey(continued) ~ Activate `main_dlg_cur` `page_Sketch_control_btn` 1;\
mapkey(continued) ~ Command `ProCmdDwgDraftGrid` ;#GRID PARAMS;#X&Y SPACING;15;#DONE/RETURN;\
mapkey(continued) #SHOW GRID;~ Command `ProCmdObjActUI` 1;\
%.ifcp;\
mapkey(continued) ~ Input `file_open` `Inputname` `D:\\ProE Standards\\Config\\on_grid.pro`;\
mapkey(continued) ~ Command `ProFileSelPushOpen_Standard@context_dlg_open_cmd` ;\
mapkey(continued) ~ Activate `ribbon_options_dialog` `OkPshBtn`;

 

1 reply

tbraxton
22-Sapphire II
22-Sapphire II
April 29, 2022

Yes, it is possible to implement a toggle for this. It will require the creation of config files that redefine the mapkey and then loading those config files to change the mapkey to the opposite logic state. It will not be a true toggle as there is an assumption on the initial state of the function you are setting.

 

Here is an example of a toggle mapkey implementation. It toggles the selection glow config option. This is a hidden config option so you will not find it in the documentation.

 

Note that the mapkey definition is changed on the fly by loading a config.pro file from invoking the mapkey. You will need to copy the path in the mapkey of the config file calls or edit them for your use.

 

Here are the mapkey definitions required to implement this toggle function. The config.pro files needed to support this are posted for reference.

 

 

!* Load config file
mapkey .ifcp @MAPKEY_NAMEImport config .pro;@MAPKEY_LABELRead config;\
mapkey(continued) ~ Select `main_dlg_cur` `appl_casc`;~ Close `main_dlg_cur` `appl_casc`;\
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`;



!*selection glow
mapkey $F4 @MAPKEY_LABELGlow Toggle;%.ifcp;\
mapkey(continued) ~ Input `file_open` `Inputname` `D:\\ProE Standards\\Config \
mapkey(continued) Calls\\on_glow.pro`;\
mapkey(continued) ~ Command `ProFileSelPushOpen_Standard@context_dlg_open_cmd` ;\
mapkey(continued) ~ Activate `ribbon_options_dialog` `OkPshBtn`;

 

 

 

 

 

Video demo of how it works

SR_CAD13-AquamarineAuthor
13-Aquamarine
April 29, 2022

Hi, thank you for your response.

There are some things that I didn't understand and as a result I didn't manage to make it work.

 

I put the code for .ifcp & $F4 in my main config file, and I created 2 others config files where I put the code for no_glow and on_glow.

 

In those files, I changed the directory from :

mapkey(continued) ~ Input `file_open` `Inputname` `D:\\ProE Standards\\Config \
mapkey(continued) Calls\\on_glow.pro`;\

To : 

mapkey(continued) ~ Input `file_open` `Inputname` `Y:\\myfile\\workdirectory \
mapkey(continued) Calls\\on_glow.pro`;\

When I use the F4 key, the system can't open the document. In the Name of the file , it's written "Y:\myfile\workdirectory Calls\on_glow.pro".

tbraxton
22-Sapphire II
22-Sapphire II
April 29, 2022

Take a bottom up debug  approach:

Create a test environment where only the mapkeys to be tested are loaded in session while debugging. ($F4, ifcp)

Make sure that you do not have any mnemonic conflicts with the mapkeys, if you use the step above you can skip this. Creo should warn you about this but check anyway.

Verify that $F4 and .ifcp mapkeys are in session in the options editor UI.

Test the .ifcp mapkey manually. Does it open the interface to load a config.pro?

 

If .ifcp is working then the most likely issue is the syntax of your path used to call the on/off config files. The syntax must be exacting for it to work.

 

To get the syntax correct use the mapkey recorder when invoking .ifcp to load both the on and off config.pro files.