NX二次开发-获取面的外围边和孔槽边
函数:
UF_MODL_ask_face_loops() 获取面的所有封闭边组合(多组edge)
UF_MODL_ask_loop_list_count() 获取loop的数量(面上孔、槽的数量+1)
UF_MODL_ask_loop_list_item() 获取loop成员,和成员有三种:外围=1, 孔槽=2, 其他=3,第四个参数为edge链
UF_MODL_ask_list_count()获取边链中边的数量
UF_MODL_ask_list_item()获取边链的成员
函数说明:使用UF_MODL_ask_loop_list_item()获取面的外围边和孔槽边,如下图
1 #include "Text.h" 2 //设置选择的实体类型 3 static int init_proc_select_faces(UF_UI_selection_p_t select, void *user_data) 4 { 5 int errorCode = 0; 6 //只是选择面 7 int num_triples = 1; //选择类型 数量 8 UF_UI_mask_t mask_triples[] = { UF_face_type,0,0 }; //定义选择类型 9 10 errorCode = UF_UI_set_sel_mask(select, UF_UI_SEL_MASK_CLEAR_AND_ENABLE_SPECIFIC, num_triples, mask_triples); 11 if (errorCode == 0) 12 { 13 return UF_UI_SEL_SUCCESS; 14 } 15 else 16 { 17 return UF_UI_SEL_FAILURE; 18 } 19 } 20 21 int Text_UI_select_faces(vector<tag_t> *vecFaces) 22 { 23 //调用API 24 char *message = "提示:选择面"; 25 char *title = "标题:选择面"; 26 int scope = UF_UI_SEL_SCOPE_ANY_IN_ASSEMBLY;//选取范围 27 int response; 28 int count = 0; 29 tag_p_t object; 30 UF_UI_select_with_class_dialog(message, title, scope, init_proc_select_faces, NULL, &response, &count, &object); 31 for (int i = 0; i < count; i++) 32 { 33 tag_t tagObj = object[i]; 34 //取消高亮显示 35 UF_DISP_set_highlight(tagObj, 0); 36 (*vecFaces).push_back(tagObj); 37 } 38 return 0; 39 /* 40 ----------------------------------------使用方法---------------------------------------- 41 vector<tag_t> vecFaces; 42 Text_UI_select_faces(&vecFaces); 43 for (int i = 0; i < vecFaces.size(); i++) 44 { 45 46 } 47 */ 48 } 49 50 extern DllExport void ufusr(char *param, int *returnCode, int rlen) 51 { 52 UF_initialize(); 53 vector<tag_t> vecFaces; 54 Text_UI_select_faces(&vecFaces); 55 for (int i = 0; i < vecFaces.size(); i++) 56 { 57 //面上所有的loops 58 uf_loop_t *loop_list = NULL; 59 UF_MODL_ask_face_loops(vecFaces[i],&loop_list); 60 //loops的个数 61 int loops_count = 0; 62 UF_MODL_ask_loop_list_count(loop_list, &loops_count); 63 64 vector<tag_t> vecHighlight; 65 //------------------------------------------------------------------------- 66 uc1601("即将高亮面的外围边", 1); 67 for (int j = 0; j < loops_count; j++) 68 { 69 int type = 0; 70 uf_list_t*hole_list = NULL; 71 UF_MODL_ask_loop_list_item(loop_list, j, &type, &hole_list); 72 if (type == 1)//外围=1, 孔槽=2, 其他=3 73 { 74 int hole_edge_count = 0; 75 UF_MODL_ask_list_count(hole_list, &hole_edge_count); 76 77 for (int k = 0; k < hole_edge_count; k++) 78 { 79 //链表中的边tag 80 tag_t hole_edge_tag = NULL_TAG; 81 UF_MODL_ask_list_item(hole_list, k, &hole_edge_tag); 82 UF_DISP_set_highlight(hole_edge_tag, 1); 83 vecHighlight.push_back(hole_edge_tag); 84 } 85 } 86 } 87 uc1601("即将取消高亮面的外围边", 1); 88 for (int j = 0; j < vecHighlight.size(); j++) 89 { 90 UF_DISP_set_highlight(vecHighlight[j], 0); 91 } 92 vecHighlight.clear(); 93 //------------------------------------------------------------------------- 94 //------------------------------------------------------------------------- 95 uc1601("即将高亮面的孔槽边", 1); 96 for (int j = 0; j < loops_count; j++) 97 { 98 int type = 0; 99 uf_list_t*hole_list = NULL; 100 UF_MODL_ask_loop_list_item(loop_list, j, &type, &hole_list); 101 if (type == 2)//外围=1, 孔槽=2, 其他=3 102 { 103 int hole_edge_count = 0; 104 UF_MODL_ask_list_count(hole_list, &hole_edge_count); 105 106 for (int k = 0; k < hole_edge_count; k++) 107 { 108 //链表中的边tag 109 tag_t hole_edge_tag = NULL_TAG; 110 UF_MODL_ask_list_item(hole_list, k, &hole_edge_tag); 111 UF_DISP_set_highlight(hole_edge_tag, 1); 112 vecHighlight.push_back(hole_edge_tag); 113 } 114 } 115 } 116 uc1601("即将取消高亮面的孔槽边", 1); 117 for (int j = 0; j < vecHighlight.size(); j++) 118 { 119 UF_DISP_set_highlight(vecHighlight[j], 0); 120 } 121 vecHighlight.clear(); 122 //------------------------------------------------------------------------- 123 } 124 125 UF_terminate(); 126 } 127 128 extern int ufusr_ask_unload(void) 129 { 130 return (UF_UNLOAD_IMMEDIATELY); 131 }