这里要注意一点,有界平面是body,不是face,以前我刚开始做项目的时候一直以为有界平面是face,后来发现不对。是body
1 NX9+VS2012 2 3 4 #include <uf.h> 5 #include <uf_modl.h> 6 7 8 UF_initialize(); 9 10 //创建四条直线(封闭) 11 UF_CURVE_line_t LineCoods1; 12 LineCoods1.start_point[0] = 0.0; 13 LineCoods1.start_point[1] = 0.0; 14 LineCoods1.start_point[2] = 0.0; 15 LineCoods1.end_point[0] = 100.0; 16 LineCoods1.end_point[1] = 0.0; 17 LineCoods1.end_point[2] = 0.0; 18 tag_t Line1Tag = NULL_TAG; 19 UF_CURVE_create_line(&LineCoods1, &Line1Tag); 20 21 UF_CURVE_line_t LineCoods2; 22 LineCoods2.start_point[0] = 100.0; 23 LineCoods2.start_point[1] = 0.0; 24 LineCoods2.start_point[2] = 0.0; 25 LineCoods2.end_point[0] = 100.0; 26 LineCoods2.end_point[1] = 100.0; 27 LineCoods2.end_point[2] = 0.0; 28 tag_t Line2Tag = NULL_TAG; 29 UF_CURVE_create_line(&LineCoods2, &Line2Tag); 30 31 UF_CURVE_line_t LineCoods3; 32 LineCoods3.start_point[0] = 100.0; 33 LineCoods3.start_point[1] = 100.0; 34 LineCoods3.start_point[2] = 0.0; 35 LineCoods3.end_point[0] = 0.0; 36 LineCoods3.end_point[1] = 100.0; 37 LineCoods3.end_point[2] = 0.0; 38 tag_t Line3Tag = NULL_TAG; 39 UF_CURVE_create_line(&LineCoods3, &Line3Tag); 40 41 UF_CURVE_line_t LineCoods4; 42 LineCoods4.start_point[0] = 0.0; 43 LineCoods4.start_point[1] = 100.0; 44 LineCoods4.start_point[2] = 0.0; 45 LineCoods4.end_point[0] = 0.0; 46 LineCoods4.end_point[1] = 0.0; 47 LineCoods4.end_point[2] = 0.0; 48 tag_t Line4Tag = NULL_TAG; 49 UF_CURVE_create_line(&LineCoods4, &Line4Tag); 50 51 //创建有界平面 52 UF_STRING_t sSection; 53 UF_MODL_init_string_list(&sSection); 54 UF_MODL_create_string_list(1, 4, &sSection); 55 sSection.num = 1; 56 sSection.string[0] = 4; 57 sSection.dir[0] = UF_MODL_CURVE_START_FROM_BEGIN; 58 sSection.id[0] = Line1Tag; 59 sSection.id[1] = Line2Tag; 60 sSection.id[2] = Line3Tag; 61 sSection.id[3] = Line4Tag; 62 63 double DistanceTol; 64 double AngleTol; 65 UF_MODL_ask_distance_tolerance(&DistanceTol);//长度公差 66 UF_MODL_ask_angle_tolerance(&AngleTol);//角度公差 67 double Tol[3] = {DistanceTol, AngleTol * DEGRA, 0.02}; 68 69 tag_t BpBodyTag = NULL_TAG; 70 UF_MODL_create_bplane(&sSection, Tol, &BpBodyTag);//创建有界平面 71 UF_MODL_free_string_list(&sSection);//释放内存 72 73 UF_terminate();