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

Community Tip - Visit the PTCooler (the community lounge) to get to know your fellow community members and check out some of Dale's Friday Humor posts! X

Mapkey Toggle Grid (HIDE Grid / SHOW Grid)

SR_CAD
12-Amethyst

Mapkey Toggle Grid (HIDE Grid / SHOW Grid)

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.

1 ACCEPTED SOLUTION

Accepted Solutions

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`;

 

View solution in original post

8 REPLIES 8
tbraxton
21-Topaz II
(To:SR_CAD)

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

========================================
Involute Development, LLC
Consulting Engineers
Specialists in Creo Parametric
SR_CAD
12-Amethyst
(To:tbraxton)

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
21-Topaz II
(To:SR_CAD)

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.

========================================
Involute Development, LLC
Consulting Engineers
Specialists in Creo Parametric
SR_CAD
12-Amethyst
(To:tbraxton)

Hi,

The problem indeed came from the syntax of my path.

I change from :

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

To : 

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

I took off the "Calls" part, I don't know if my version of the code do the same job or if it's a bit worst but it seems to be working great atm.

It might be because my software is in french so it doesn't recognize "Calls", but I couldn't find a french word to do the work.

 

I will now look into the Mapkey Toggle Grid.

Have a good WE.

SR_CAD
12-Amethyst
(To:SR_CAD)

I manage to create a toggle grid but it only works in sketcher for .prt. I used "sketcher_disp_grid" but couldn't find the grid for .drw

The code was pretty much the same, I mainly change "enable_selection_glow yes" to "sketcher_disp_grid no".

 

tbraxton
21-Topaz II
(To:SR_CAD)

This is a new problem that is not easily solved as the UI works differently depending on what mode is active in Creo. You will find differences between part mode and assembly mode for instance even for the same function but a mapkey created in part mode will not work in assembly. This is not an area where I have seen much contribution from the user base.

 

See this thread on multimode mapkey implementation.

https://community.ptc.com/t5/3D-Part-Assembly-Design/Strategies-to-implement-multi-mode-mapkey-functionality/m-p/191625#M8799 

========================================
Involute Development, LLC
Consulting Engineers
Specialists in Creo Parametric

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`;

 

SR_CAD
12-Amethyst
(To:pausob)

It's working great, thanks @tbraxton and @pausob !

Top Tags