1 NX9+VS2012 2 3 #include <uf.h> 4 #include <uf_modl.h> 5 #include <uf_ui.h> 6 #include <uf_disp.h> 7 #include <uf_obj.h> 8 #include <NXOpen/Annotations.hxx> 9 10 UF_initialize(); 11 12 //创建块 13 UF_FEATURE_SIGN Sign = UF_NULLSIGN; 14 double Corner_Pt[3] = {25.0, 37.0, 48.0}; 15 char *Edge_Len[3] = {"105", "135", "142"}; 16 tag_t BlkTag = NULL_TAG; 17 UF_MODL_create_block1(Sign, Corner_Pt, Edge_Len, &BlkTag); 18 19 //特征找体 20 tag_t BodyTag = NULL_TAG; 21 UF_MODL_ask_feat_body(BlkTag, &BodyTag); 22 23 //设置体颜色 24 UF_OBJ_set_color(BodyTag, 186); 25 26 //特征找边 27 uf_list_p_t EdgeList; 28 UF_MODL_ask_feat_edges(BlkTag, &EdgeList); 29 30 //获取链表数量 31 int Count; 32 UF_MODL_ask_list_count(EdgeList, &Count); 33 34 //转换 35 char msg1[256]; 36 sprintf_s(msg1, "当前体有%d条边 每条边的两个端点如下: ", Count); 37 //打印 38 UF_UI_open_listing_window(); 39 UF_UI_write_listing_window(msg1); 40 for (int i = 0; i < Count; i++) 41 { 42 //获取链表里的tag 43 tag_t Edge_Tag = NULL_TAG; 44 UF_MODL_ask_list_item(EdgeList, i, &Edge_Tag); 45 46 //高亮所有边 47 UF_DISP_set_highlight(Edge_Tag, 1); 48 49 //获取边的端点 50 double Point1[3]; 51 double Point2[3]; 52 int PointNum; 53 UF_MODL_ask_edge_verts(Edge_Tag, Point1, Point2, &PointNum); 54 55 //转换 56 char msg2[256]; 57 sprintf_s(msg2, "X坐标:%.0f, Y坐标:%.0f, Z坐标:%.0f X坐标:%.0f, Y坐标:%.0f, Z坐标:%.0f ", Point1[0], Point1[1], Point1[2], Point2[0], Point2[1], Point2[2]); 58 //打印 59 UF_UI_write_listing_window(msg2); 60 } 61 62 UF_terminate();