cancel
Showing results for 
Search instead for 
Did you mean: 

Executing a Macro from NXOpen API

Solution Partner Creator Solution Partner Creator
Solution Partner Creator

Hi, Is it possible to execute a Macro from NXOpen or Callback in any of the NX version?

 

Regards,

Ashish

4 REPLIES

Re: Executing a Macro from NXOpen API

Experimenter
Experimenter

Hi,

 

this code works in NX 8.5 - not tested in any higher versions:

 

        [DllImport("libugui.dll", EntryPoint = "?MACRO_playback_from_usertool@@YAXPBD@Z")]
        static extern void MACRO_playback_from_usertool32(string lpName);

        [DllImport("libugui.dll", EntryPoint = "?MACRO_playback_from_usertool@@YAXPEBD@Z")]
        static extern void MACRO_playback_from_usertool64(string lpName);

        /// <summary>
        /// Run NX Macro files
        /// </summary>
        /// <param name="lpname">Macro File Name</param>
        public static void RunMacro(string lpname) {
            if (IntPtr.Size == 8) {
                MACRO_playback_from_usertool64(lpname);
            } else {
                MACRO_playback_from_usertool32(lpname);
            }
        }

 

Re: Executing a Macro from NXOpen API

Siemens Phenom Siemens Phenom
Siemens Phenom

 

Good morning.  I feel like I should mention that there is no supported way to do this.

 

Calling obfuscated internal functions that are intentionally not exposed in the NX Open API kits might work, but there is no guarantee that it will continue to work in future versions. 

 

Best regards,

 

Steve

 

Re: Executing a Macro from NXOpen API

Solution Partner Creator Solution Partner Creator
Solution Partner Creator

Hi SteGa, your code works fine for me in NX8, this is what I needed but I have a small problem in it, I have to call multiple macros from program, when I use this code and call multiple macros only the last macro is executed, there are no errors or exception, in logfile I can see other macros getting called but not executed. Have you got such issue?

Re: Executing a Macro from NXOpen API

Experimenter
Experimenter
Hi,

good to hear it works.
We are using this method only in one special case to call a macro in the end of an NXOpen dll execution.
I think this is a known limitation that only one macro can be executed at the end of NXOpen runtime.