Showing results for 
Search instead for 
Do you mean 

Executing a Macro from NXOpen API

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





Re: Executing a Macro from NXOpen API



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) {
            } else {


Re: Executing a Macro from NXOpen API


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,




Re: Executing a Macro from NXOpen API

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


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.