1 NX11+VS2013 2 3 #include <uf.h> 4 #include <uf_modl.h> 5 #include <NXOpen/Face.hxx> 6 #include <uf_ui.h> 7 #include <NXOpen/NXObjectManager.hxx> 8 #include <NXOpen/Edge.hxx> 9 10 11 UF_initialize(); 12 13 //获取选择面控件选择的对象 14 PropertyList* FaceSelectProps = face_select0->GetProperties(); 15 std::vector<NXOpen::TaggedObject *> Faces = FaceSelectProps->GetTaggedObjectVector("SelectedObjects"); 16 delete FaceSelectProps; 17 FaceSelectProps = NULL; 18 19 for (int i = 0; i < Faces.size(); i++) 20 { 21 NXOpen::Face *MyFace = dynamic_cast<NXOpen::Face *>(Faces[i]); 22 23 std::vector<tag_t> FaceNum; 24 uf_loop_p_t Loop_List; 25 UF_MODL_ask_face_loops(MyFace->Tag(), &Loop_List);//查询面的边界 26 27 int LoopNum; 28 UF_MODL_ask_loop_list_count(Loop_List, &LoopNum);//查询面的边界链表数量 29 30 int LoopChildType; 31 int Num1; 32 uf_list_p_t LoopChildList; 33 char msg[256]; 34 std::vector<tag_t> edge; 35 UF_MODL_create_list(&LoopChildList);//创建链表 36 for (int j = 0; j < LoopNum; j++) 37 { 38 UF_MODL_ask_loop_list_item(Loop_List, j, &LoopChildType, &LoopChildList);//查询面的边界类型 39 if (LoopChildType == 2)//类型为内边界的时候 40 { 41 UF_MODL_ask_list_count(LoopChildList, &Num1);//查询链表数量 42 43 for (int n = 0; n < Num1; n++) 44 { 45 tag_t objTag = NULL_TAG; 46 UF_MODL_ask_list_item(LoopChildList, n, &objTag);//获取链表里的tag 47 edge.push_back(objTag); 48 } 49 } 50 51 } 52 53 sprintf_s(msg, "当前有%d个孔", edge.size()); 54 uc1601(msg, 1); 55 56 UF_MODL_delete_list(&LoopChildList); 57 UF_MODL_delete_loop_list(&Loop_List); 58 } 59 60 UF_terminate();