Skip to main content
12-Amethyst
January 27, 2022
Solved

Running 2 mapkeys on Creo start

  • January 27, 2022
  • 14 replies
  • 6151 views

Hi all,

When I start Creo (4.0), I let it open and execute a trail file to init some things, depending on the project I am working on.
The main thing it does, is to execute 2 mapkeys.
One mapkey sets the current working directory of this specific project.
The other mapkey opens the main assembly of this project.

This trail file looks like this:

 

!trail file version No. 1400
!Pro/ENGINEER TM Wildfire 4.0 (c) 2010 by Parametric Technology Corporation All Rights Reserved.
!!!! Resize window
~ Activate `main_dlg_cur` `main_dlg_cur`
~ Resize `main_dlg_cur` `main_dlg_cur` \
4 0.000000 0.000000 48.759963 26.053753
!!!! Play the 'init' mapkey
~ Command `ProCmdUtilMacros` 1
~ Select `mapkey_main` `list_mapkeys` 1 `init`
~ Activate `mapkey_main` `RunButton`
~ Activate `mapkey_main` `CloseButton`
!End of Trail File

 

It opens the 'Mapkey' dialog box, selects the 'init' mapkey and runs this.
Then closes the Mapkey dialog box.

The thing is ... this doesn't work. The 'init' mapkey is not run.
It DOES work when I edit the trail file by removing the Close command.
So remove this line:
~ Activate `mapkey_main` `CloseButton`

 

Then init mapkey is executed correctly, but the Mapkey Dialog Box remains open, which I don't like because then I have to manually close it.
So it looks like the trail file does not wait until the 2 mapkeys have finished their job. It closes the Mapkey box too early, interrupting the 2 mapkeys (or prevents them from even executing).

Can anybody give any tips or work-arounds to have the 2 mapkeys executed and the Mapkey box closed?

Oh, the reason that those 2 separate mapkeys exist, is that I often use them while working on the project. To quickly open the main assembly and to quickly go back to the project working directory (in case I temporarily set another working directory).
So I change the definition of those 2 mapkeys for each of my projects.

Init mapkey is nothing more than:
mapkey init %sww;%om;

Best answer by EddyVE

Hi,

I managed to solve my problem by moving the
~ Activate `mapkey_main` `CloseButton`
line to the end of the 'init' mapkey and removing it from the trail file.
The Mapkeys Dialog Box is now closed in the end, but not prematurely, so the 2 mapkeys 'sww' and 'om' are executed fine.
BTW. Everything happens so fast that the Mapkeys Dialog Box does not show up at all.

Here is the modified trail file:

 

!trail file version No. 1400
!Creo TM 4.0 (c) 2022 by PTC Inc. All Rights Reserved.
!!!!
~ Command `ProCmdUtilMacros` 1
~ Select `mapkey_main` `list_mapkeys` 1 `init`
~ Activate `mapkey_main` `RunButton`
!~ Activate `mapkey_main` `CloseButton` <--- Line commented out
!End of Trail File

 

The relevant mapkeys:

 

mapkey sww @MAPKEY_NAMESet working directory;\
mapkey(continued) @MAPKEY_LABELSet_Working_Directory;~ Close `main_dlg_cur` `appl_casc`;\
mapkey(continued) ~ Command `ProCmdSessionChangeDir` ;\
mapkey(continued) ~ Trail `UI Desktop` `UI Desktop` `DLG_PREVIEW_POST` `file_open`;\
mapkey(continued) ~ Update `file_open` `Inputname` \
mapkey(continued) `D:\\Projects\\BigProject`;\
mapkey(continued) ~ Command `ProFileSelPushOpen@context_dlg_open_cmd`;

 

mapkey om @MAPKEY_NAMEOpen main assembly;@MAPKEY_LABELOpen_main;\
mapkey(continued) ~ Select `main_dlg_cur` `appl_casc`;~ Close `main_dlg_cur` `appl_casc`;\
mapkey(continued) ~ Command `ProCmdModelOpen` ;\
mapkey(continued) ~ Trail `UI Desktop` `UI Desktop` `DLG_PREVIEW_POST` `file_open`;\
mapkey(continued) ~ Update `file_open` `Inputname` \
mapkey(continued) `MAIN.asm`;\
mapkey(continued) ~ Activate `file_open` `Inputname`;

 

mapkey init @MAPKEY_LABELInit;\
mapkey(continued) %sww;%om;\
mapkey(continued) ~ Activate `mapkey_main` `CloseButton`;

 

Thanks your input and your time to reply!

 

 

14 replies

EddyVE12-AmethystAuthor
12-Amethyst
January 27, 2022

I will try to move the Close command into the 'init' mapkey. See if that does the trick ....

 

KenFarley
21-Topaz II
January 27, 2022

Wouldn't it be easier to just define another mapkey, setting it to something easy like $F7 or whatever, and then when you start up Creo you just hit F7 to call the mapkey? The F7 mapkey would just call the two "sww" and "om" mapkeys you must be defining in you config.pro.

 

In other words, what I would probably do is:

(1) Define the "sww" and "om" mapkeys as you normally do, to do the stuff you need them to do.

(2) Define a third mapkey set to something like F7 or whatever, which calls the two "sww" and "om" mapkeys.

(3) When you start a session, hit that F7 or whatever and it will do your stuff.

 

Bringing in a trail file seems like it's a bit more complicated than things need to be.

EddyVE12-AmethystAuthor
12-Amethyst
January 27, 2022

That's a possibility. But this is all about saving keypresses. I can also just close the Mapkey Dialog Box with one mouseclick....

I sometimes spend hours or days, just to try to find a way to save one or two mouseclicks (or keypresses) .... 🙂 

tbraxton
22-Sapphire II
January 27, 2022

Assuming the dialogue box is the issue, avoid opening it. You should not have to open the mapkey dialogue box to implement this. If you record the trail file without accessing the map key dialogue box it may resolve the issue. Have you tried this?

 

I just ran a test in Creo 4 where I built equivalent mapkeys to yours. When I run the nested mapkey using keyboard input it changes directory and opens the assembly without launching any UI elements (dialogue box).

 

Mapkeys I created for testing:

mapkey *ots %ra;~ Select `file_open` `Ph_list.Filelist` 1 `asm0001_test.asm`;\
mapkey(continued) ~ Activate `file_open` `Ph_list.Filelist` 1 `asm0001_test.asm`;
mapkey *tst %micd;~ Activate `file_open` `SAB_d:`;\
mapkey(continued) ~ Select `file_open` `Ph_list.Filelist` 1 `Projects`;\
mapkey(continued) ~ Activate `file_open` `Ph_list.Filelist` 1 `Projects`;\
mapkey(continued) ~ Select `file_open` `Ph_list.Filelist` 1 `Test`;\
mapkey(continued) ~ Activate `file_open` `Ph_list.Filelist` 1 `Test`;\
mapkey(continued) ~ Command `ProFileSelPushOpen@context_dlg_open_cmd`;

mapkey .i %*tst;%*ots;

 

Trail file used to execute mapkeys which is working for me. It runs the nested mapkey (.i) as soon as Creo opens.

!trail file version No. 1861
!Creo TM 4.0 (c) 2022 by PTC Inc. All Rights Reserved.
!playing mapkey .i
~ Close `main_dlg_cur` `appl_casc`
~ Command `ProCmdSessionChangeDir` 
< 2 0.118519 178 0 0 100 2560 0 0 1440 13
!mem_use INCREASE Blocks 802573, AppSize 101598881, SysSize 117758616
~ Trail `UI Desktop` `UI Desktop` `DLG_PREVIEW_POST` \
 `file_open`
~ Trail `UI Desktop` `UI Desktop` `DLG_PREVIEW_POST` \
 `file_open`
~ Activate `file_open` `SAB_d:`
~ Select `file_open` `Ph_list.Filelist` 1 `Projects`
~ Activate `file_open` `Ph_list.Filelist` 1 `Projects`
~ Select `file_open` `Ph_list.Filelist` 1 `Test`
~ Activate `file_open` `Ph_list.Filelist` 1 `Test`
~ Command `ProFileSelPushOpen@context_dlg_open_cmd` 
!%CISuccessfully changed to D:\Projects\Test directory.
~ Command `ProCmdModelOpen` 
< 2 0.118519 178 0 0 100 2560 0 0 1440 13
~ Trail `UI Desktop` `UI Desktop` `DLG_PREVIEW_POST` \
 `file_open`
~ Trail `UI Desktop` `UI Desktop` `DLG_PREVIEW_POST` \
 `file_open`
~ Open `file_open` `Type`
~ Close `file_open` `Type`
~ Select `file_open` `Type` 1 `db_1`
~ Select `file_open` `Ph_list.Filelist` 1 `asm0001_test.asm`
~ Activate `file_open` `Ph_list.Filelist` 1 `asm0001_test.asm`
!Command ProCmdModelOpenExe was pushed from the software.
!27-Jan-22 12:12:12 Start D:\Projects\Test\asm0001_test.asm.1
!27-Jan-22 12:12:12 End D:\Projects\Test\asm0001_test.asm.1
!End of Trail File

 

EddyVE12-AmethystAuthor
12-Amethyst
January 27, 2022

Yes, but then you have the asm file name and the working directory embedded in the trail file. And it is also stored in the 2 mapkeys 'sww' en 'om'.
What I had before was something similar: the file and path name stored in 2 different places. I want to have it stored in just one place. That is simpler when I have to create a new project.

 

My first idea was to find a way to store file and path name into a few variable(s). Then use these variables in the trail file and the mapkeys. But I didn't find a way to do that ....

 

EddyVE12-AmethystAuthorAnswer
12-Amethyst
January 27, 2022

Hi,

I managed to solve my problem by moving the
~ Activate `mapkey_main` `CloseButton`
line to the end of the 'init' mapkey and removing it from the trail file.
The Mapkeys Dialog Box is now closed in the end, but not prematurely, so the 2 mapkeys 'sww' and 'om' are executed fine.
BTW. Everything happens so fast that the Mapkeys Dialog Box does not show up at all.

Here is the modified trail file:

 

!trail file version No. 1400
!Creo TM 4.0 (c) 2022 by PTC Inc. All Rights Reserved.
!!!!
~ Command `ProCmdUtilMacros` 1
~ Select `mapkey_main` `list_mapkeys` 1 `init`
~ Activate `mapkey_main` `RunButton`
!~ Activate `mapkey_main` `CloseButton` <--- Line commented out
!End of Trail File

 

The relevant mapkeys:

 

mapkey sww @MAPKEY_NAMESet working directory;\
mapkey(continued) @MAPKEY_LABELSet_Working_Directory;~ Close `main_dlg_cur` `appl_casc`;\
mapkey(continued) ~ Command `ProCmdSessionChangeDir` ;\
mapkey(continued) ~ Trail `UI Desktop` `UI Desktop` `DLG_PREVIEW_POST` `file_open`;\
mapkey(continued) ~ Update `file_open` `Inputname` \
mapkey(continued) `D:\\Projects\\BigProject`;\
mapkey(continued) ~ Command `ProFileSelPushOpen@context_dlg_open_cmd`;

 

mapkey om @MAPKEY_NAMEOpen main assembly;@MAPKEY_LABELOpen_main;\
mapkey(continued) ~ Select `main_dlg_cur` `appl_casc`;~ Close `main_dlg_cur` `appl_casc`;\
mapkey(continued) ~ Command `ProCmdModelOpen` ;\
mapkey(continued) ~ Trail `UI Desktop` `UI Desktop` `DLG_PREVIEW_POST` `file_open`;\
mapkey(continued) ~ Update `file_open` `Inputname` \
mapkey(continued) `MAIN.asm`;\
mapkey(continued) ~ Activate `file_open` `Inputname`;

 

mapkey init @MAPKEY_LABELInit;\
mapkey(continued) %sww;%om;\
mapkey(continued) ~ Activate `mapkey_main` `CloseButton`;

 

Thanks your input and your time to reply!