Need to trigger a dll when user changes the module. From NX Modeling to File->All Applications->mechanical Routing

Hi, I'm trying to trigger a code when user switches the application module. For example, user is in NX modeling and changes the module form File->All applications->Mechanical routing. Right after opening Mechanical Routing, I want my code to be triggered. Please let me know any mechanism to achieve the same. Thanks in advance.

One way to do this is with "MenuScript". Menuscript is a way to add custom actions to existing menu items; you can tell NX to execute your code when the user selects the mechanical routing application from the menu.

https://docs.plm.automation.siemens.com/tdoc/nx/10/nx_api/#uid:index_nxo...

Thank you for the quick response. Can you please suggest any other way to listen the changes in the File->application and triggers some code externally. I mean some external batch or an EXE to perform this action. Any suggestions would help. Thanks in advance.

"triggers some code externally"

Menuscript is able to start external code that is completely separate from NX. For instance, you could start MS Word when a user enters the drafting application.

If you mean that you want an external application to respond to events in NX; I think that is possible, but it is beyond the capabilities of a journal. At the least, you would need to compile the code and register events/callbacks in NX. I do not have the proper licensing for these operations, so I do not know the exact procedure. I would suggest consulting the programming help files and posting on the Siemens' community site or contacting GTAC directly for help.

I know this is an old thread, but in case someone else wants to do something similar...

You could create a program that uses the "startup" user exit to register an "application changed callback" then within that callback you would perform your code to detect the new/old application and respond accordingly.
Then put the dll in your "startup" folder for NX. Then when NX launches it will run your "startup" code and register the callback to run whenever the application is changed.


Imports NXOpen
Imports NXOpen.UF

Module SwitchApplicationTrigger

public function startup() as integer
dim theUI as UI = UI.GetUI
TheUI.MenuBarManager.RegisterApplicationSwitchCallback(AddressOf AppChangedCB)
Return 0
End Function

public Function AppChangedCB(appID as String, reason as Menubar.MenuBarManager.SwitchReason) as Integer
'Do code in here, detect the app that was changed, if it is changed to the right application then run your code, etc...
Return 0
end Function

I just noticed, the imports NXOpen.UF line is unneccesary