The UF_UI_create_usertool function in the uf_ui.h header file can load the specified user tool. Currently, no API function is available to run macros. However, you can load the user tool (. utd file), and then click the user tool panel to execute the corresponding macro command.
The example code is as follows:
/*************************************** * ********************************** Ufd_ui_create_usertool.c the file will demonstrate how to use the following UG/Open API functions (s): UF_UI_create_usertool environment: VS2008 compiled, tested on NX 4.0/NX 6.0. History: date Author remarks 2010-11-02 zare_lzj organize and create ********************************* **************************************** * *** // *** \ API UF_UI_create_usertool * loads the user tool (. utd file), you can run the macro (. macro ). */# Include <stdio. h> # include <uf. h> # include <uf_defs.h> # include <uf_exit.h> # include <uf_part.h> # include <uf_ui.h> # pragma comment (lib, "libufun. lib ") # pragma comment (lib," libugopenint. lib ") # define UF_CALL (X) (report_error (_ FILE __, _ LINE __, # X, (X) static int report_error (char * file, int line, char * call, int irc) {if (irc) {char err [133], messg [300]; logical response; UF_UI_is_listing_window_o Pen (& response); if (! Response) UF_UI_open_listing_window (); UF_get_fail_message (irc, err); sprintf_s (messg, 300, "\ n % s \ nerror % d at line % d in % s \ n % s", err, irc, line, file, call); UF_UI_write_listing_window (messg ); UF_UI_write_listing_window ("\ n");} return (irc);} static void do_it (void) {char * filename = "C: \ Program Files \ UGS \ NX 4.0 \ UGSAMPLES \ file_toolbar_nt.utd "; logical read_flag; UF_CALL (UF_UI_create_usertool (0, fi Lename, UF_UI_SHOW, & read_flag); if (read_flag) uc1601 ("Syntax error! ", 1);} void ufusr (char * param, int * retcode, int paramLen) {if (UF_CALL (UF_initialize () return; if (UF_PART_ask_display_part ()! = NULL_TAG) do_it (); elseuc1601 ("No active part", 1); UF_terminate () ;}int ufusr_ask_unload (void) {return (Signature) ;}void ufusr_cleanup (void) {return ;}