1 NX9+VS2012 2 3 #include <uf.h> 4 #include <uf_modl.h> 5 #include <uf_obj.h> 6 #include <uf_ui.h> 7 8 9 UF_initialize(); 10 11 //创建圆柱 12 UF_FEATURE_SIGN Sign = UF_NULLSIGN; 13 double Origin[3] = {0.0, 0.0, 0.0}; 14 char *Height = "100"; 15 char *Diam = "50"; 16 double Direction[3] = {0.0, 0.0, 1.0}; 17 tag_t CylTag = NULL_TAG; 18 UF_MODL_create_cyl1(Sign, Origin, Height, Diam, Direction, &CylTag); 19 20 //特征找体 21 tag_t BodyTag = NULL_TAG; 22 UF_MODL_ask_feat_body(CylTag, &BodyTag); 23 24 //体找面 25 uf_list_p_t FaceList; 26 UF_MODL_ask_body_faces(BodyTag, &FaceList); 27 28 //获取链表数量 29 int Count; 30 UF_MODL_ask_list_count(FaceList, &Count); 31 32 UF_UI_open_listing_window(); 33 //获取链表里的tag 34 for (int i = 0; i < Count; i++) 35 { 36 tag_t FaceTag = NULL_TAG; 37 UF_MODL_ask_list_item(FaceList, i, &FaceTag); 38 39 //获取面的法向 40 int Type; 41 double Point[3]; 42 double Dir[3]; 43 double Box[6]; 44 double Radius[3]; 45 double RadData[3]; 46 int NormDir; 47 UF_MODL_ask_face_data(FaceTag, &Type, Point, Dir, Box, Radius, RadData, &NormDir); 48 49 //找圆柱侧面 50 if (Type == 16)//对比面的类型 51 { 52 //对圆柱侧面设置颜色 53 UF_OBJ_set_color(FaceTag, 186); 54 55 //打印面的法向方向 56 char msg[256]; 57 sprintf_s(msg, "面的法向方向为: X:%.0f Y:%.0f Z:%.0f ", Dir[0], Dir[1], Dir[2]); 58 UF_UI_write_listing_window(msg); 59 } 60 } 61 62 //释放内存 63 UF_MODL_delete_list(&FaceList); 64 65 UF_terminate();