NX9二次开发培训作业001_使用ufcre入口函数
本帖最后由 清江 于 2014-11-19 10:45 编辑11月16日培训课程的作业,运行效果如下图:
开发代码如下:
/* Include files */
#include <stdio.h>
#include <stdarg.h>
#include <uf.h>
#include <uf_ui.h>
static void ECHO(char *format, ...)
{
char msg;
va_list args;
va_start(args, format);
vsnprintf_s(msg, sizeof(msg), UF_UI_MAX_STRING_LEN, format, args);
va_end(args);
UF_UI_open_listing_window();
UF_UI_write_listing_window(msg);
UF_print_syslog(msg, FALSE);
}
#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;
UF_get_fail_message(irc, err);
ECHO("*** ERROR code %d at line %d in %s:\n",
irc, line, file);
ECHO("+++ %s\n", err);
ECHO("%s;\n", call);
}
return(irc);
}
/*****************************************************************************
**Activation Methods
*****************************************************************************/
/*New Part
** This user exit is invoked after the following menu item is activated:
** "File->New" */
extern DllExport void ufcre( char *param, int *returnCode, int rlen )
{
/* Initialize the API environment */
if( UF_CALL(UF_initialize()) )
{
/* Failed to initialize */
return;
}
/* TODO: Add your application code here */
uc1601("新建部件名称规则:XjfXXX(Xjf000)",1);
/* Terminate the API environment */
UF_CALL(UF_terminate());
}
/*****************************************************************************
**Utilities
*****************************************************************************/
/* Unload Handler
** This function specifies when to unload your application from Unigraphics.
** If your application registers a callback (from a MenuScript item or a
** User Defined Object for example), this function MUST return
** "UF_UNLOAD_UG_TERMINATE". */
extern int ufusr_ask_unload( void )
{
return( UF_UNLOAD_IMMEDIATELY );
}
厉害,学习
页:
[1]