马上注册,结交更多同行朋友,交流,分享,学习。
您需要 登录 才可以下载或查看,没有帐号?注册
x
int SHEET_ok ( 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 );
//变量申明
char * sVariable="UGII_USER_DIR";
char * sTranslation;
char sSheetName[30]="";//视图名称
UF_STYLER_item_value_type_t value;
char sTemplatePath[255]="";//模板路径
char sDTemplatePath[255]="";//标注模板
int iSheetSelect=0;//图框选择
char *sMillTemplate="\\application\\SheetTemplate\\A3_H_Mill.prt";
char *sTurnTemplate="\\application\\SheetTemplate\\A3_H_Turn.prt";
char *DraftingTemplate="\\application\\SheetTemplate\\template.prt";
char buff[254]="";
tag_t tPart_CurrPath;
char sPart_Fspec[ 256 + 1 ];
int num_drawings;
tag_p_t drawing_tags;
int mpi_array[100];
double mpr_array[70];
char rad_symbol[27], dia_symbol[27];
tag_t part;
UF_PART_load_status_t error_status;
tag_t note_tag=NULL_TAG;
double origin_3d[ 3 ]={57,-2.2,0};
char * text_string[1];
char str[254]="";
UF_DRAW_info_t drawing_info;
tag_t drawing_tag;
drawing_info.drawing_scale=1;
UF_import_part_modes_t modes;
modes.layer_mode=0;
modes.group_mode=1;
modes.view_mode=0;
double dest_csys[ 9],x_vec[ 3 ]={1,0,0},y_vec[ 3 ]={0,1,0};
double dest_point[ 3 ]={0,0,0};
tag_t group ;
drawing_info.units=UF_PART_METRIC;
drawing_info.size_state=UF_DRAW_CUSTOM_SIZE;
drawing_info.projection_angle=UF_DRAW_FIRST_ANGLE_PROJECTION;
drawing_info.size.custom_size[0]=420;
drawing_info.size.custom_size[1]=298;
int SheetSign=0,PathSign=0,DraftingSign=0;
/********************************输入查询*********************************/
//新图标识DraftingSign
value.item_id=SHEET_NEW_DRAWING;
value.item_attr=UF_STYLER_VALUE;
UF_STYLER_ask_value (dialog_id, &value);
DraftingSign=value.value.integer;
//图框标识SheetSign
value.item_id=SHEET_IMAGE;
value.item_attr=UF_STYLER_VALUE;
UF_STYLER_ask_value (dialog_id, &value);
SheetSign=value.value.integer;
//路径标识PathSign
value.item_id=SHEET_PATH;
value.item_attr=UF_STYLER_VALUE;
UF_STYLER_ask_value (dialog_id, &value);
PathSign=value.value.integer;
//sprintf(buff,"%d;%d;%d",DraftingSign,SheetSign,PathSign);
//uc1601(buff,1);
/********************************部件标识*********************************/
tPart_CurrPath=UF_ASSEM_ask_work_part ( ); //获得当前工作部件标识
UF_PART_ask_part_name (tPart_CurrPath,sPart_Fspec); //查询部件路径
/********************************基本参数查询*********************************/
//查询图框选择
value.item_id=SHEET_SELECT ;
value.item_attr=UF_STYLER_VALUE;
UF_STYLER_ask_value (dialog_id, &value);
iSheetSelect=value.value.integer;
//取文件路径
UF_translate_variable (sVariable, &sTranslation); //取环境变量
strcpy(sTemplatePath,sTranslation);
strcpy(sDTemplatePath,sTranslation);
switch(iSheetSelect)
{case 0: strcat(sTemplatePath,sMillTemplate); break;
case 1: strcat(sTemplatePath,sTurnTemplate); break;
default: uc1601("图框选择错误!",1);
}
strcat(sDTemplatePath,DraftingTemplate);
//查询视图名字
value.item_id=SHEET_NAME ;
value.item_attr=UF_STYLER_VALUE;
UF_STYLER_ask_value (dialog_id, &value);
strcpy(sSheetName,value.value.string);
/*********************************功能选取*********************************/
/*********************************功能创建*********************************/
UF_DRAW_ask_drawings (&num_drawings, &drawing_tags );
//判断视图名称是否重复
for(int i=0;i<num_drawings;i++){
UF_OBJ_ask_name (drawing_tags, buff);
if(strcmp(strupr(sSheetName),buff)==0){
strcat(sSheetName,"_1");
//uc1601(buff,1);
i=0;
}
}
UF_free (drawing_tags );
//1:创建视图
if(DraftingSign==1)
UF_DRAW_create_drawing (sSheetName, &drawing_info, & drawing_tag );
//2:导入图框
if(SheetSign==1){
UF_MTX3_initialize (x_vec, y_vec, dest_csys);
UF_PART_import (sTemplatePath, &modes, dest_csys, dest_point, 1, &group );
}
//3:设置标准模板参数
UF_PART_open (sDTemplatePath, &part, &error_status );
UF_DRF_ask_preferences (mpi_array, mpr_array, rad_symbol, dia_symbol );
UF_PART_close (part, 0, 1 );
UF_PART_set_display_part (tPart_CurrPath );
UF_DRF_set_preferences (mpi_array, mpr_array, rad_symbol, dia_symbol );
//4:创建路径标注
text_string[0]=str;
strcpy(str,"模型路径:");
strcat(str,sPart_Fspec);
if(PathSign==1)
UF_DRF_create_note (1, text_string, origin_3d, 0, ¬e_tag );
UF_terminate ();
/* Callback acknowledged, terminate dialog */
/* It is STRONGLY recommended that you exit your */
/* callback with UF_UI_CB_EXIT_DIALOG in a ok callback.*/
/* return ( UF_UI_CB_EXIT_DIALOG ); */
return (UF_UI_CB_EXIT_DIALOG);
} |