UG二次开发模板(2)函数模板
函数模板1, uc1600 //获取字符串头文件:#include <uf_ui.h>int res = 0; int len = 0; char string=""; res = uc1600( "",string , &len );//string:Input / Output if ( res == 5 || ( res== 3 && len > 0 ) ) { } else { } 2, uc1603 // 头文件:#include <uf_ui.h> 用法1: char title ="菜单"; char items [ 38 ] = { "选项1","选项2","选项3"}; choice = uc1603(title, 0, items, 3); if (choice == 1 || choice == 2) { UF_terminate(); } else { if (choice == ) { } }用法2: char items [ 38 ] = { "选项1","选项2","选项3"}; response = uc1603( "菜单", 0, items, 3 ); switch ( response ) { case 1: case 2: break; case 4: case 5: } 3,选择对话框头文件 头文件1: init_proc_face static intinit_proc_face( UF_UI_selection_p_t select, void* user_data ){ int nums = 1; UF_UI_mask_t masks[] = { UF_solid_type, 0,UF_UI_SEL_FEATURE_ANY_FACE}; if((UF_UI_set_sel_mask(select, UF_UI_SEL_MASK_CLEAR_AND_ENABLE_SPECIFIC, nums, masks)) ==0) { return(UF_UI_SEL_SUCCESS); } else { return(UF_UI_SEL_FAILURE); }} 头文件2:init_proc_bodystatic int init_proc_body(UF_UI_selection_p_t select, void* user_data){ int num_triples = 1; UF_UI_mask_t mask_triples[] = {UF_solid_type, 0, UF_UI_SEL_FEATURE_BODY}; /* enableonly lines and edges */ if((UF_CALL(UF_UI_set_sel_mask(select, UF_UI_SEL_MASK_CLEAR_AND_ENABLE_SPECIFIC, num_triples, mask_triples))) == 0) { return (UF_UI_SEL_SUCCESS); } else { return (UF_UI_SEL_FAILURE); }} 4,UF_UI_select_with_single_dialog头文件:#include <uf_ui.h> char title[]=""; char cue[] =""; int response=0; double cursor ; tag_t face = NULL; tag_t view = NULL; if(!UF_CALL(UF_UI_select_with_single_dialog(cue, title, UF_UI_SEL_SCOPE_NO_CHANGE, init_proc_face,NULL, &response,&face,cursor ,&view))) { if (response == UF_UI_OBJECT_SELECTED || response == UF_UI_OBJECT_SELECTED_BY_NAME) { printf("object tag = %d\n", face); } UF_DISP_set_highlight(face, 0);//关高亮 }5,UF_UI_select_with_class_dialog头文件:#include <uf_ui.h>void class_sel_dlg(int*count,tag_p_t *objects){ char cue[] = ""; char title[] = ""; int response, sel_count, i; tag_p_t sel_objects; if((UF_CALL(UF_UI_select_with_class_dialog( cue, title, UF_UI_SEL_SCOPE_NO_CHANGE, init_proc_face, NULL, &response, &sel_count,&sel_objects))) == 0) { printf("object count = %d\n",sel_count); if (response == UF_UI_OK && sel_count > 0) { *objects=sel_objects; *count=sel_count; for (i=0; i<sel_count; i++) { printf("object tag = %d\n",sel_objects); UF_DISP_set_highlight(sel_objects, 0); } UF_free(objects); } } }6,UF_MODL_delete_object_parms//消参头文件:#include< uf_modl.h>#include< uf_modl_utilities.h > uf_list_p_t obj_list; UF_CALL(UF_MODL_create_list(&obj_list)); UF_CALL(UF_MODL_put_list_item(obj_list, )); UF_CALL(UF_MODL_put_list_item(obj_list, )); UF_MODL_delete_object_parms(obj_list); UF_MODL_delete_list(&obj_list);
UF_OBJ_delete_object(); 7,UF_CURVE_create_arc//通过圆心,半径画圆 头文件:#include< uf_csys.h>#include< uf_curve.h> tag_tarc, wcs_tag; UF_CSYS_ask_wcs(&wcs_tag); UF_CURVE_arc_t arc_coords; UF_CSYS_ask_matrix_of_object(wcs_tag,&wcs_tag); arc_coords.matrix_tag=wcs_tag; arc_coords.start_angle = 0.0; arc_coords.end_angle =360.0 * DEGRA; arc_coords.arc_center = center;// arc_coords.arc_center = center;// arc_coords.arc_center = center;// arc_coords.radius = 500; UF_CURVE_create_arc(&arc_coords,&arc_id); 8,UF_OBJ_set_name(tag,name); //设置名字头文件#include <uf_obj.h> 9,name开关 intname_status ; UF_DISP_ask_name_display_status(&name_status); if (name_status==UF_DISP_NAME_DISPLAY_OFF ) { name_status=UF_DISP_NAME_DISPLAY_ON; } else { name_status=UF_DISP_NAME_DISPLAY_OFF; } UF_DISP_set_name_display_status(name_status);
10,UF_OBJ_set_color(tag,color); //设置颜色头文件#include <uf_obj.h> 11,UF_OBJ_set_layer(tag,layer); //设置层头文件#include <uf_obj.h> 12,UF_CALL头文件#include <uf.h> int UF_CALL ( interrorCode ){ if ( errorCode ) { char message = ""; UF_get_fail_message( errorCode, message ); uc1601 ( message, 1); } return (errorCode);} 13, UF_PART_ask_display_part头文件#include <uf_part.h> tag_t part = UF_PART_ask_display_part( ); if ( NULL == part ) { uc1601( "", 1 ); return; } 14,UF_OPER_create头文件#include <uf_oper.h> tag_t Oper_id = NULL; UF_OPER_create ( "mill_contour","ZLEVEL_PROFILE_YBC", &GZM_Oper_id ); 15,UF_MODL_ask_face_data//查询面的信息
头文件#include <uf_modl.h>tag_t face;//面的ID inttype; //面的类型 double box;//x,y,z向最大,最小值 double radius; double rad_data; intnorm_dir ;//法向 UF_MODL_ask_face_data(face,&type,center, dir,box,&radius,&rad_data,&norm_dir); 16,UF_MODL_ask_minimum_dist_2//查询两物体间距离 doubledis,accuracy;// accuracy:准确度double point1={0};double point2={0}; UF_CALL(UF_MODL_ask_minimum_dist_2 ( obj1, obj2, 0, NULL, 0,NULL, & dis, point1, point1,&accuracy ));
页:
[1]