马上注册登录,享用更多网站功能!
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
我把清华那本书上面的那个UDO2程序试了一下,运行没有错误,但是结果不对!具体表现是:可以作出那个block,但是uc1601相关的显示却没有出现(也就是回调函数没有执行)!但是当我把block删除后可能(因为不是每次都出现,时有时无)出现 “in display event”。各位大虾帮忙看看原因是什么,顺便提下udo有什么优势!
主要代码如下:
void registed_display_fun(tag_t udo, void *display_context)
{
int errorCode = UF_initialize();
uc1601("in display event" , 1);
errorCode = UF_terminate();
}
void registed_select_fun(tag_t udo, void *select_context)
{
int errorCode = UF_initialize();
uc1601("in select event" , 1);
errorCode = UF_terminate();
}
void registed_fit_fun(tag_t udo, void *select_context)
{
UF_UDOBJ_all_data_t all_data;
char *class_name , *friendly_name;
int errorCode = UF_initialize();
uc1601("in fit event" , 1);
errorCode = UF_UDOBJ_ask_udo_data ( udo, [$all_data)]
 rintErrorMessage(errorCode);
errorCode = UF_UDOBJ_ask_class_data( all_data.class_id,
[$class_name, & friendly_name )]
 rintErrorMessage(errorCode);
UF_UDOBJ_free_udo_data( [$all_data )]
uc1601( class_name, 1);
uc1601( friendly_name, 1);
UF_free( class_name);
UF_free( friendly_name );
errorCode = UF_terminate();
}
/* Unigraphics Startup
** This entry point activates the application at Unigraphics startup */
extern DllExport void ufsta( char *param, int *returnCode, int rlen )
{
/* Initialize the API environment */
int errorCode = UF_initialize();
if ( 0 == errorCode )
{
/* TODO: Add your application code here */
/* Terminate the API environment */
errorCode = UF_terminate();
}
/* Print out any error messages */
 rintErrorMessage( errorCode );
}
/* Explicit Activation
** This entry point is used to activate the application explicitly, as in
** "File->Execute UG/Open->User Function..." */
extern DllExport void ufusr( char *parm, int *returnCode, int rlen )
{
double block_orig[3] = {0.0, 0.0, 0.0};
char *block_len[3] = {"1", "2", "3"};
tag_t block_tag;
UF_FEATURE_SIGN sign = UF_NULLSIGN;
UF_UDOBJ_class_t class_id;
tag_t udo_tag = NULL_TAG;
UF_UDOBJ_link_t link_defs[1];
// void *select_contex;
/* Initialize the API environment */
int errorCode = UF_initialize();
if ( 0 == errorCode )
{
UF_MODL_create_block1(sign, block_orig, block_len, [$block_tag)]
errorCode = UF_UDOBJ_create_class("UDOTestClass", "MY_UDO", [$class_id)]
 rintErrorMessage( errorCode);
errorCode = UF_UI_add_to_class_sel(class_id);
 rintErrorMessage(errorCode);
errorCode = UF_UDOBJ_create_udo( class_id, [$udo_tag )]
 rintErrorMessage(errorCode);
link_defs[0].link_type = 1;
link_defs[0].assoc_ug_tag = block_tag;
link_defs[0].object_status = 0;
errorCode = UF_UDOBJ_add_links(udo_tag, 1, link_defs);
 rintErrorMessage(errorCode);
errorCode = UF_UDOBJ_add_owning_links(udo_tag ,1, [$block_tag)]
 rintErrorMessage(errorCode);
errorCode = UF_UDOBJ_register_display_cb(class_id, registed_display_fun);
 rintErrorMessage(errorCode);
errorCode = UF_UDOBJ_register_select_cb(class_id, registed_select_fun);
 rintErrorMessage(errorCode);
errorCode = UF_UDOBJ_register_fit_cb( class_id, registed_fit_fun);
PrintErrorMessage(errorCode);
errorCode = UF_terminate();
}
/* Print out any error messages */
PrintErrorMessage( errorCode );
}
程序附件如下: |