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

Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X

Running 2 mapkeys on Creo start

EddyVE
10-Marble

Running 2 mapkeys on Creo start

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;

1 ACCEPTED SOLUTION

Accepted Solutions
EddyVE
10-Marble
(To: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!

 

 

View solution in original post

14 REPLIES 14
EddyVE
10-Marble
(To:EddyVE)

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

 

KenFarley
21-Topaz I
(To:EddyVE)

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.

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

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

 

========================================
Involute Development, LLC
Consulting Engineers
Specialists in Creo Parametric
EddyVE
10-Marble
(To:tbraxton)

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 ....

 

EddyVE
10-Marble
(To:tbraxton)

If I could find a way to call a mapkey from a trail file without having to open the Mapkey Dialog Box, that would solve my problem.
And also without embedding the filenames in the trail file.

 

tbraxton
21-Topaz II
(To:EddyVE)

I am with @KenFarley about using a trail file to do this.

All of you goals/constraints were not clear in the initial post. If you documented your requirements in more detail that would be useful for those responding.

 

One can invoke any in session mapkey (with a valid mnemonic for keyboard entry) without using the mapkey dialogue box. Since this will be recorded in a trail file it should not be an issue. I am not following why you are not able to do this.

 

You could run an external OS script instead of a trail file and then use any variables available in the scripting tool to change path and file names. This script could edit a trail file if that is what you want to do.

========================================
Involute Development, LLC
Consulting Engineers
Specialists in Creo Parametric
EddyVE
10-Marble
(To:tbraxton)

Sorry that my initial post was not clear to describe exactly what I was looking for. It is not always easy to describe a problem in sufficient detail to other people.

I know that I am probably nitpicking, but this issue has been a thorn in my side for quite some time.

Anyway, I found a solution. See my other post.

 

EddyVE
10-Marble
(To:tbraxton)

On a side note.

What is the function of %ra and %micd in your mapkeys?

 

mapkey *ots %ra;~ Select ......

mapkey *tst %micd;~ Activate ......

 

tbraxton
21-Topaz II
(To:EddyVE)

Those are mapkeys.

%ra = retrieve assembly

%micd = change directory

========================================
Involute Development, LLC
Consulting Engineers
Specialists in Creo Parametric
EddyVE
10-Marble
(To:tbraxton)

Yes, I figured they are mapkeys, but I don't understand what their function is in relation to the mapkeys they are used in here.

I first thought that perhaps %ra and %micd where fetching the needed file and folder names from somewhere. But since the file and folder name is embedded in the mapkeys shown it has me confused...

tbraxton
21-Topaz II
(To:EddyVE)

The filename and directory path are not defined by the mapkeys. These are mapkeys I already had in my config and they are structured such that nested mapkeys can be built from them which is what I did for this case.

 

%ra is not file specific it can open any assembly

%micd is not path specific it can navigate to any supplied path

 

This would lend itself to your use of a trail file where you can change the filename and path for your assembly to open.

 

 

========================================
Involute Development, LLC
Consulting Engineers
Specialists in Creo Parametric
EddyVE
10-Marble
(To:tbraxton)

Ok. Got it!

Thanks for explaining!

 

EddyVE
10-Marble
(To: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!

 

 

Top Tags