点击查看详细介绍

UF_UI_open_part() 函数的参数解释说明、函数详细用法,以及实例代码演示

misnn 7年前 1652 0

购买与咨询 NX 二次开发视频教程,请联系微信号:13890821008  QQ号:85585969  


函数结构:
UF_UI_open_part
(
const UF_UI_err_p_t error_fn,
char * file_name,
logical * unused,
tag_t * part,
int * response,
UF_PART_load_status_t * error_status
)

函数说明:
打开一个组成部分,使得它使用文件工作的一部分 - >打开文件选择对话框。

函数参数:
第1个参数为输入:
error_fn代表参数变量,const UF_UI_err_p_t 为输入参数类型,指针的数据结构和用户定义的错误处理功能。

第2个参数为输入:
输入char * 字符类型的参数,参数的变量格式为file_name,在默认的输入部分名称用于部分打开的对话框。关于输出到打开零件的名称。

第3个参数为输入:
unused代表参数变量,logical * 为输入参数类型,参数不再使用;离开前向兼容性

第4个参数为输出:
part代表参数变量,tag_t * 为输出参数类型,指针刚开业的一部分标记(如响应仅适用= UF_UI_OK)。

第5个参数为输出:
输出int * 整数型的参数,参数的变量格式为response,从对话框用户响应:UF_UI_OK UF_UI_CANCEL

第6个参数为输出:
error_status代表参数变量,UF_PART_load_status_t * 为输出参数类型,用户分配的结构<&ERROR_STATUS GT;填充有名称和未正确加载任何部件相关联的错误代码。分配的数组必须与UF_free_string_array和UF_free()进行释放。详情参见UF_PART_load_status_t的定义。

UF_UI_open_part函数实例代码演示:
下面的例子演示了如何调用UF_UI_open_part.Include文件
[quote]
#include <stdio.h>
#include <string.h>
#include <uf.h>
#include <uf_part.h>
#include <uf_ui.h>
/* ***** Local Prototype ***** */
static logical my_error_handler
(
UF_UI_err_data_p_t error_fn_data,
char *file_name,
int error,
UF_PART_load_status_t *error_status,
logical *skip_error_disp
);
/* ***** Entry Point ***** */
/*ARGSUSED*/
extern void ufusr ( char *param , int *ret_code , int len )
{
/*
*********************
variable declarations
*********************
*/
int response;
tag_t part_tag = NULL_TAG;
char file_name [ MAX_FSPEC_SIZE + 1 ] = "flange.prt";
const char *message = "part open error";
logical use_display_file = FALSE;
UF_PART_load_status_t part_status;
UF_UI_err_t error_handler;

/*
************************************************
initialize the 'struct' as an open part 'struct'
and assign the local function prototyped above
as the callback
************************************************
*/
error_handler.type = UF_UI_open_part_fun;
error_handler.fun.open = my_error_handler;
/*
************************************************
assign the client data and its size
Note: this is an arbitrary usage of the client
data. A better use might be to pass the name of
a UIStyler dialog which would then be invoked in
the callback
************************************************
*/
error_handler.fun_data.size = strlen ( message ) + 1;
error_handler.fun_data.data = message;
/*
*************************************************
call the function, free any allocated memory
*************************************************
*/
UF_initialize ( );
UF_UI_open_part ( &error_handler , file_name ,
&use_display_file ,
&part_tag , &response , &part_status );
if ( part_status.statuses != NULL )
{
UF_free ( part_status.statuses );
}
if ( part_status.file_names != NULL )
{
UF_free_string_array ( part_status.n_parts ,
part_status.file_names );
}
UF_terminate ( );
}
/* ***** local function to be invoked as a callback ***** */
static logical my_error_handler
(
UF_UI_err_data_p_t error_fn_data,
char *file_name,
int error,
UF_PART_load_status_t *error_status,
logical *skip_error_disp
)
{
/*
***************************************************
this function trivially just prints the client data
that it receives as well as the file name and the
error
As mentioned above, a better usage of the client
data would be to pass through the name of a
UIStyler dialog to display. Such a use might
resemble the following:
UF_STYLER_create_dialog (
( char * ) error_fn_data->data ,
callbacks ,
n_callbacks ,
NULL ,
&response );
***************************************************
*/
fprintf ( stderr , "my_error_handler called with:\n"
" error_fn_data->size = %d\n"
" error_fn_data->data = %s\n"
" file_name = %s\n"
" error = %d\n" ,
error_fn_data->size ,
( const char * ) error_fn_data->data ,
file_name ,
error
);
/* **************************************************
instruct NX to display its error dialog and to
continue looping within the dialog until a part
is opened
**************************************************
*/
*skip_error_disp = TRUE;
return TRUE;
}




[/quote]

0

最新回复 (0)
请登录后发表新帖