📄 block.cpp
字号:
If you wish to have this dialog displayed from the callback of 你想从另一个UIStyler dialog的回调函数显示对话框
another UIStyler dialog, you should:
1) Make sure that the callback of your UIStyler dialog is
designated as a dialog building callback. 确定你UIStyler dialog的回调函数被指定为对话框构建的回调
2) Remove the conditional definitions:
#ifdef DISPLAY_FROM_CALLBACK
#endif DISPLAY_FROM_CALLBACK
3) Your callback should issue a call to this function. 你的回调发布一个对此函数的调用
4) You should also add the funcitonal prototype to your header file 你赢该加入函数圆形到头文件,确认文件
(block.h) and ensure that the file is properly included.存在
All dialog files must be located in 所有文件都定位到以下 目录
$UGII_USER_DIR/application or
$UGII_SITE_DIR/application or
$UGII_VENDOR_DIR/application directory
--------------------------------------------------------------*/
//#ifdef DISPLAY_FROM_CALLBACK
extern DllExport int BlockFun( int *response )
{
int error_code = 0;
if ( ( error_code = UF_initialize() ) != 0 )
return (0) ;
tag_t tPrtWorkPart=UF_ASSEM_ask_work_part();
tag_t part_open;
char part_fspec[MAX_FSPEC_SIZE+1];
UF_PART_load_status_t error_status_open;
if(tPrtWorkPart!=NULL_TAG)
{
if(UF_PART_is_modified(tPrtWorkPart)!=0)
{
uc1601("模型已被修改,请先保存!",1);
return (0) ;
}
UF_PART_ask_part_name(tPrtWorkPart,part_fspec);
UF_PART_close(tPrtWorkPart,1,0);
UF_PART_open_quiet(part_fspec,&part_open,&error_status_open);
UF_free_string_array(error_status_open.n_parts,error_status_open.file_names);
UF_free(error_status_open.statuses);
}
const char env[255]="UGII_USER_DIR";
char *basedir=NULL;
basedir=getenv(env);
char dir[100];
char prompt[5]="新建";
char title[5]="新建";
char filename[50];
int response_dial;
tag_t part;
UF_PART_load_status_t error_status;
mark_1:
strcpy(dir,basedir);
strcat(dir,"\\ug_user_prt\\*.prt");
UF_UI_create_filebox(prompt,title,dir,NULL,filename,&response_dial);
if(response_dial==UF_UI_OK)
{
strcpy(dir,basedir);
strcat(dir,"\\ug_prt\\block.prt");
part=NULL_TAG;
if(UF_PART_open(dir,&part,&error_status)!=0)
{
uc1601("种子文件路径错误或种子路径不存在!",1);
UF_free_string_array(error_status.n_parts,error_status.file_names);
UF_free(error_status.statuses);
return (UF_UI_CB_CONTINUE_DIALOG);
}
UF_free_string_array(error_status.n_parts,error_status.file_names);
UF_free(error_status.statuses);
if(UF_PART_save_as(filename)!=0)
{
uc1601("文件名在内存或硬盘上已存在,请重新输入文件名!",1);
UF_PART_close(part,1,0);
goto mark_1;
}
}
else
{
return (0) ;
}
if ( ( error_code = UF_STYLER_create_dialog ( "block.dlg",
BLOCK_cbs, /* Callbacks from dialog */
BLOCK_CB_COUNT, /* number of callbacks*/
NULL, /* This is your client data */
response ) ) != 0 )
{
char fail_message[133];
/* Get the user function fail message based on the fail code.*/
UF_get_fail_message(error_code, fail_message);
UF_UI_set_status (fail_message);
printf ( "%s\n", fail_message );
}
UF_terminate();
return (error_code);
}
//#endif /* DISPLAY_FROM_CALLBACK */
/*-------DIALOG CREATION FROM A USER EXIT HELP Example --------
To create this dialog from a user exit, you must invoke a
call to the NX Open API, UF_STYLER_create_dialog. An example
is shown below.
All dialog files must be located in
$UGII_USER_DIR/application or
$UGII_SITE_DIR/application or
$UGII_VENDOR_DIR/application directory
1) Remove the conditional definitions:
#ifdef DISPLAY_FROM_USER_EXIT
#endif DISPLAY_FROM_USER_EXIT
2) Add a user exit to the function name below, for example, ufusr.
3) Consider how your shared library will be unloaded. Take a look
at the generated function ufusr_ask_unload.
--------------------------------------------------------------*/
#ifdef DISPLAY_FROM_USER_EXIT
extern void ufusr (char *param, int *retcode, int rlen)
{
int response = 0;
int error_code = 0;
if ( ( UF_initialize() ) != 0 )
return;
UF_terminate();
return;
}
/*--------------------------------------------------------------------------
This function specifies how a shared image is unloaded from memory
within Unigraphics. This function gives you the capability to unload an
internal NX Open application or user exit from Unigraphics. You can
specify any one of the three constants as a return value to determine
the type of unload to perform: immediately after user function
execution, via an unload selection dialog, or when Unigraphics terminates
terminates. If you choose UF_UNLOAD_SEL_DIALOG, then you have the
option to unload your image by selecting File->Utilities->Unload Shared
Image.
NOTE: A program which associates NX Open applications with the menubar
MUST NOT use this option since it will UNLOAD your NX Open application image
--------
from the menubar.
--------------------------------------------------------------------------*/
extern int ufusr_ask_unload (void)
{
/* unload immediately after application exits*/
return ( UF_UNLOAD_IMMEDIATELY );
/*via the unload selection dialog... */
/*return ( UF_UNLOAD_SEL_DIALOG ); */
/*when UG terminates... */
/*return ( UF_UNLOAD_UG_TERMINATE ); */
}
/*--------------------------------------------------------------------------
You have the option of coding the cleanup routine to perform any housekeeping
chores that may need to be performed. If you code the cleanup routine, it is
automatically called by Unigraphics.
--------------------------------------------------------------------------*/
extern void ufusr_cleanup (void)
{
return;
}
#endif /* DISPLAY_FROM_USER_EXIT */
/*-------------------------------------------------------------------------*/
/*---------------------- UIStyler Callback Functions ----------------------*/
/*-------------------------------------------------------------------------*/
/* -------------------------------------------------------------------------
* Callback Name: BLOCK_construction
* This is a callback function associated with an action taken from a
* UIStyler object.
*
* Input: dialog_id - The dialog id indicate which dialog this callback
* is associated with. The dialog id is a dynamic,
* unique id and should not be stored. It is
* strictly for the use in the NX Open API:
* UF_STYLER_ask_value(s)
* UF_STYLER_set_value
* client_data - Client data is user defined data associated
* with your dialog. Client data may be bound
* to your dialog with UF_MB_add_styler_actions
* or UF_STYLER_create_dialog.
* callback_data - This structure pointer contains information
* specific to the UIStyler Object type that
* invoked this callback and the callback type.
* -----------------------------------------------------------------------*/
int BLOCK_construction ( int dialog_id,
void * client_data,
UF_STYLER_item_value_type_p_t callback_data)
{
/* Make sure User Function is available. */
if ( UF_initialize() != 0)
return ( UF_UI_CB_CONTINUE_DIALOG );
/* ---- Enter your callback code here ----- */
tag_t curr_part,*exps;
double arExpValue[3];
int num_of_exps=0;
curr_part=UF_PART_ask_nth_part(0);
UF_MODL_ask_exps_of_part(curr_part,&num_of_exps,&exps);
if(num_of_exps==0)
uc1601("模型中没有表达式存在!",1);
for(int i=0;i<num_of_exps;i++)
{
UF_MODL_ask_exp_tag_value(exps[i],&arExpValue[i]);
}
UF_free(exps);
UF_STYLER_item_value_type_t data1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -