Cancel
Showing results for 
Search instead for 
Did you mean: 

Changing menu item function or callback between applications

Creator
Creator

I've written a journal file that I want to run every time an entity is deleted when in the Drafting module. Right now I've created a Menuscript that modifies with ACTION/POST the UG_EDIT_DELETE function. This works great except that it's also running any time something is deleted in any application, which is a waste of resources.

 

What i'm wondering is, if there is a way to use Menuscripts to change the UG_EDIT_DELETE action between my Post function when in Drafting and simply the Standard function when in all other modules.

 

Or, how would you unregister a callback/re-register when the user switches between applications to achieve the same result.

 

Edit : It should also be noted that I'm running NX9.0.3.4 on Windows 7 64x programming in C#

5 REPLIES

Re: Changing menu item function or callback between applications

Esteemed Contributor
Esteemed Contributor

If nothing else, you can check (in your code) what application you are in, and if not drafting, exit.

Ken Akerboom Sr CAx Systems Engr, Moog, Inc.
Production: NX10.0.3.5 MP5 + patch/TC11.2
I'd rather be e-steemed than e-diseaseled


Re: Changing menu item function or callback between applications

Creator
Creator

I have something like that in the code already.


int appModule;
ufs.UF.AskApplicationModule(out appModule);

if (appModule != 1)

    return;

 

It seem's like there's still a little lag between when I delete something and when it updates.

Re: Changing menu item function or callback between applications

Siemens Phenom Siemens Phenom
Siemens Phenom

You can have one custom .MEN file in the startup folder that is used to specify that you want to run another custom .MEN file from the application folder when you enter a particular application.

 

Search for the keyword "MENU_FILES" in the Menuscript docs.

 

In your custom file in the application folder, you would modify the behavior of the delete button, just when you are in Drafting.

 

For example, to specify menu changes that only happen in Drafting, put this in a file in startup:

 

VERSION 120

EDIT UG_GATEWAY_MAIN_MENUBAR

MODIFY

  APPLICATION_BUTTON UG_APP_DRAFTING
  MENU_FILES my_drafting_mods.men

END_OF_MODIFY

!! ==================

 

Then in the application folder, add a pre and post action for update view:

 

VERSION 120

EDIT UG_GATEWAY_MAIN_MENUBAR

MODIFY

    BUTTON UG_DRAFT_DRW_UPDATE_VIEW
    ACTIONS/PRE pre_action.dll
    ACTIONS/POST post_action.dll
    
END_OF_MODIFY

 

 

(I realize you need a different action, but this was handy and it sound like you already know what the menu mods should look like.)

 

 

 

 

 

Re: Changing menu item function or callback between applications

Creator
Creator

I was trying to use the MENU_FILES function without success. I've made it work in the past but I can only seem to get it to work when it's modifing application specific functions. Like if I use it on APPLICATION_BUTTON UG_APP_DRAFTING then the menu file specified with MENU_FILES can then modify functions like UG_DRAFT_DRW_MODIFY or UG_DRAFT_DRW_INCREMENT_REVISION. That works fine but when I try to have it modify UG_EDIT_DELETE it doesnt work.

 

Below is my drafting customize .men from Startup

 

VERSION 120
EDIT UG_GATEWAY_MAIN_MENUBAR
MODIFY
 APPLICATION_BUTTON UG_APP_DRAFTING
 MENU_FILES em_custom_draft.men
END_OF_MODIFY

 

Then I have the following em_custom_draft.men in Application...

 

VERSION 120
EDIT UG_GATEWAY_MAIN_MENUBAR
MODIFY
 BUTTON UG_DRAFT_DRW_INCREMENT_REVISION
 ACTIONS/POST em_custom_func.cs

 BUTTON UG_DRAFT_DRW_UPDATE_VIEW
 ACTIONS/PRE em_custom_func.cs

 BUTTON UG_EDIT_DELETE
 ACTIONS/POST em_custom_func.cs  
END_OF_MODIFY

 

The others work but the UG_EDIT_DELETE does not. Am I missing something?

Re: Changing menu item function or callback between applications

Siemens Phenom Siemens Phenom
Siemens Phenom

 

Your menus look fine.  Please report this to GTAC so we can investigate, and submit a PR if we can reproduce it.  Thanks!