Showing results for 
Search instead for 
Do you mean 
Reply
Solved! Go to solution

Can I use MenuScript to add a PRE action to a button that is defined in a TBR file?

I've never had need to use MenuScript much. I've dabbled with adding a new menu item to the main menu bar and stuff but just the basics.

 

Now I have a toolbar (.TBR file) that is loaded at startup and one of the buttons launches one of my NXOpen BlockDialog applications. This application loads UDFs into the part from our standard UDF library.

 

However, each of our sites also has their own local UDF library. In the past someone set up 2 macros to switch between these UDF libraries which are activated by buttons on another toolbar.

 

To make sure my NXOpen app uses the correct UDF library I'd like to add a PRE action to the button that launches it so the macro to switch to the standard UDF library gets executed. This will ensure that my app looks in the correct UDF library, and I won't have to rely on the users remembering to do it before hand.

 

Is it possible to add a PRE action to a button that is defined in a .TBR file? And if so, can it execute a macro? And how to do it?

Graham Inchley Snr R&D Engineer (Systems Development), Sandvik Coromant
Lenovo ThinkPad W540, Win7, 16GB. Developing in: Java | C | C# | KF
Production: NX8.5.3.3 MP11 64bit Testing: NX9.0.2.5
22 REPLIES

Re: Can I use MenuScript to add a PRE action to a button that is defined in a TBR file?

The NX documentation contains the entire help for the Menuscript programming language.

I would not only use a TBR file, since in the MEN file you have much more options and control of how things work.

The TBR file should only contain the BUTTON statements, which get controlled in the MEN file.

 

Example MEN file:

 

!
! Haidlmair Main Menu Changes
!

VERSION 120

EDIT UG_GATEWAY_MAIN_MENUBAR

AFTER   UG_HELP

CASCADE_BUTTON MY_MAIN_MENU
LABEL My Menu

END_OF_AFTER

MENU MY_MAIN_MENU
BUTTON MY_GEN_TOOL_PATH LABEL Generate tool path MESSAGE Generates the tool path of the selected program groups without interruption BITMAP CAM_Prefs.bmp ACTIONS ${UGII_INITIAL_JOURNAL_DIR}\${UGII_VERSION}\GenerateToolPath.dll ACTIONS/PRE ${UGII_INITIAL_JOURNAL_DIR}\${UGII_VERSION}\CAMcleanSuppressedGeometry.dll END_OF_MENU

 

Example TBR file:

 

!
! Haidlmair Manufacturing Toolbar
!

TITLE       My Manufacturing
VERSION     160
! DOCK      NO

BUTTON      MY_GEN_TOOL_PATH

 

Stefan Pendl, Systemmanager CAx, HAIDLMAIR GmbH
Production: NX10.0.3, VERICUT 8.0, FBM, MRL 3.1.4 | TcUA 10.1 MP7 Patch 0 (10.1.7.0) | TcVis 10.1
Development: VB.NET, Tcl/Tk    Testing: NX11.0 EAP, NX12.0 EAP

How to Get the Most from Your Signature in the Community

Re: Can I use MenuScript to add a PRE action to a button that is defined in a TBR file?

I've had a go with your solution, but I can't get it to work I'm afraid. Using 2 DLLs it works fine, but I want to have an ACTION/PRE that is a macro and an ACTION that is a Java .class file. This seems to not be possible.

I tried a macro for both ACTION/PRE and ACTION, but only the ACTION/PRE executed.

I tried a macro for ACTION/PRE and a DLL for ACTION, but again only the ACTION/PRE executed.

I cannot get a Java .class file to execute at all from a button defined in a .MEN file. However it works fine from a .TBR file.

Graham Inchley Snr R&D Engineer (Systems Development), Sandvik Coromant
Lenovo ThinkPad W540, Win7, 16GB. Developing in: Java | C | C# | KF
Production: NX8.5.3.3 MP11 64bit Testing: NX9.0.2.5

Re: Can I use MenuScript to add a PRE action to a button that is defined in a TBR file?

I think a JAR file should be supported, since this is a signed NXOpen Java program.

Stefan Pendl, Systemmanager CAx, HAIDLMAIR GmbH
Production: NX10.0.3, VERICUT 8.0, FBM, MRL 3.1.4 | TcUA 10.1 MP7 Patch 0 (10.1.7.0) | TcVis 10.1
Development: VB.NET, Tcl/Tk    Testing: NX11.0 EAP, NX12.0 EAP

How to Get the Most from Your Signature in the Community

Re: Can I use MenuScript to add a PRE action to a button that is defined in a TBR file?

Would it be possible to translate the macro logic into your Java code to eliminate the need for a macro pre-action entirely?

Re: Can I use MenuScript to add a PRE action to a button that is defined in a TBR file?

[ Edited ]

@Stefan_Pendl

We use an Equinox OSGi container for executing our projects as plugins within NX. This gives us a number of benefits, but it does mean we don't actually produce individual JAR files for our projects. So, no we can't reference a JAR in the .MEN file Smiley Sad

 

@cowski1

Unfortunately what the macro does is modify the path to the UDF database (.def) and library (.txt) fields that define the UDF library. As far as I can tell this is just not covered anywhere in the NX API.

The reason we have this is that we have NX used in over 30 offices all over the world and each one has its own server. The UDF library for the whole group is distributed to all of these so everyone has the same standard UDFs. But each site can generate their own UDFs which they store locally. So they switch between the global and local UDF library to access whichever they need. Manually this is not complicated, but involves browsing for the two files mentioned above which is fiddly for users. So having two macros to switch to the global or local library was the solution.

Graham Inchley Snr R&D Engineer (Systems Development), Sandvik Coromant
Lenovo ThinkPad W540, Win7, 16GB. Developing in: Java | C | C# | KF
Production: NX8.5.3.3 MP11 64bit Testing: NX9.0.2.5

Re: Can I use MenuScript to add a PRE action to a button that is defined in a TBR file?

Have you tried changing the customer default through API, I know that one can read them via NXOpen.Session.GetSession().OptionsManager methods.

There is also coverage of changing preferences at runtime.

Do you use the reuse library or the legacy UDF library?

Stefan Pendl, Systemmanager CAx, HAIDLMAIR GmbH
Production: NX10.0.3, VERICUT 8.0, FBM, MRL 3.1.4 | TcUA 10.1 MP7 Patch 0 (10.1.7.0) | TcVis 10.1
Development: VB.NET, Tcl/Tk    Testing: NX11.0 EAP, NX12.0 EAP

How to Get the Most from Your Signature in the Community

Re: Can I use MenuScript to add a PRE action to a button that is defined in a TBR file?

We're using the legacy UDF library.

I just did a little investigation into the SessionPreferences and there is a heap of interesting stuff in there, I'll have hours of fun playing with that and the other stuff available from Session. I feel a bit naive not having explored that more in the past Man LOL

However, I couldn't see anything that would directly do what I wanted, which is set the paths to the UDF library files.

BUT I did see a method that I had forgotten about:

setEnvironmentVariableValue()

This led me to look in the NX log file to see if I could find the 2 files that define the UDF library, and hey-presto there they are under:

UGII_UDF_DEFINITION_FILE
UGII_UDF_DATABASE_FILE

I haven't tried it yet, but I believe I can set these using the method mentioned. I'm busy with something else right now, but when I've tried it I'll report back here.

Thanks for the pointer.

Graham Inchley Snr R&D Engineer (Systems Development), Sandvik Coromant
Lenovo ThinkPad W540, Win7, 16GB. Developing in: Java | C | C# | KF
Production: NX8.5.3.3 MP11 64bit Testing: NX9.0.2.5

Re: Can I use MenuScript to add a PRE action to a button that is defined in a TBR file?

In the past setting environment variables was only possible in the Gateway application, so you might have to change applications before changing the variable.

Stefan Pendl, Systemmanager CAx, HAIDLMAIR GmbH
Production: NX10.0.3, VERICUT 8.0, FBM, MRL 3.1.4 | TcUA 10.1 MP7 Patch 0 (10.1.7.0) | TcVis 10.1
Development: VB.NET, Tcl/Tk    Testing: NX11.0 EAP, NX12.0 EAP

How to Get the Most from Your Signature in the Community

Re: Can I use MenuScript to add a PRE action to a button that is defined in a TBR file?

Thanks for the heads up, I'll give it a try.

Graham Inchley Snr R&D Engineer (Systems Development), Sandvik Coromant
Lenovo ThinkPad W540, Win7, 16GB. Developing in: Java | C | C# | KF
Production: NX8.5.3.3 MP11 64bit Testing: NX9.0.2.5