合并面并删除参数
1 // NX 8.5.3.3 2 // Journal created by Administrator on Mon Apr 20 11:21:24 2020 中国标准时间 3 // 4 #include "C:\\all_uf.h" 5 #include <uf_defs.h> 6 #include <NXOpen/NXException.hxx> 7 #include <NXOpen/Session.hxx> 8 #include <NXOpen/BasePart.hxx> 9 #include <NXOpen/Builder.hxx> 10 #include <NXOpen/Expression.hxx> 11 #include <NXOpen/ExpressionCollection.hxx> 12 #include <NXOpen/Face.hxx> 13 #include <NXOpen/FaceDumbRule.hxx> 14 #include <NXOpen/Features_Brep.hxx> 15 #include <NXOpen/Features_DeleteFaceBuilder.hxx> 16 #include <NXOpen/Features_FeatureCollection.hxx> 17 #include <NXOpen/NXObject.hxx> 18 #include <NXOpen/Part.hxx> 19 #include <NXOpen/PartCollection.hxx> 20 #include <NXOpen/Plane.hxx> 21 #include <NXOpen/PlaneCollection.hxx> 22 #include <NXOpen/Preferences_PartModeling.hxx> 23 #include <NXOpen/Preferences_PartPreferences.hxx> 24 #include <NXOpen/Preferences_PartPreferences.hxx> 25 #include <NXOpen/Preferences_PartVisualizationLine.hxx> 26 #include <NXOpen/ScCollector.hxx> 27 #include <NXOpen/ScRuleFactory.hxx> 28 #include <NXOpen/SelectISurface.hxx> 29 #include <NXOpen/SelectObject.hxx> 30 #include <NXOpen/SelectionIntentRule.hxx> 31 #include <NXOpen/Session.hxx> 32 #include <NXOpen/TaggedObject.hxx> 33 #include <NXOpen/Unit.hxx> 34 #include <NXOpen/Face.hxx> 35 #include <NXOpen/FaceTangentRule.hxx> 36 #include <NXOpen/NXObjectManager.hxx> 37 #include <uf_defs.h> 38 #include <uf_ui_types.h> 39 #include <iostream> 40 #include <NXOpen/Session.hxx> 41 #include <NXOpen/UI.hxx> 42 #include <NXOpen/NXMessageBox.hxx> 43 #include <NXOpen/Callback.hxx> 44 #include <NXOpen/NXException.hxx> 45 #include <NXOpen/BlockStyler_UIBlock.hxx> 46 #include <NXOpen/BlockStyler_BlockDialog.hxx> 47 #include <NXOpen/BlockStyler_PropertyList.hxx> 48 #include <NXOpen/BlockStyler_Group.hxx> 49 #include <NXOpen/BlockStyler_FaceCollector.hxx> 50 #include <uf.h> 51 #include <uf_obj.h> 52 #include <NXOpen/NXObjectManager.hxx> 53 #include <NXOpen/PartCollection.hxx> 54 #include <NXOpen/Face.hxx> 55 #include <NXOpen/FaceTangentRule.hxx> 56 #include <NXOpen/ScCollectorCollection.hxx> 57 #include <NXOpen/ScRuleFactory.hxx> 58 using namespace NXOpen; 59 60 #define UF_CALL(X) (report( __FILE__, __LINE__, #X, (X))) 61 static int report(char *file, int line, char *call, int irc) 62 { 63 if (irc) 64 { 65 char messg[133]; 66 printf("%s, line %d: %s\n", file, line, call); 67 (UF_get_fail_message(irc, messg)) ? 68 printf(" returned a %d\n", irc) : 69 printf(" returned error %d: %s\n", irc, messg); 70 } 71 return(irc); 72 } 73 74 75 76 extern "C" DllExport int ufusr_ask_unload() 77 { 78 return (int)Session::LibraryUnloadOptionImmediately; 79 } 80 81 static int select_filter_proc_fn(tag_t object, int type[1], void* user_data, UF_UI_selection_p_t select) 82 { 83 //uf_list_p_t edge_list; 84 //int edge_count = 0, Type = 0; 85 //double Point[3]; 86 //double Dir[3]; 87 //double Box[6]; 88 //double Radius[3]; 89 //double RadData[3]; 90 //int NormDir, vertex_count = 0; 91 //UF_MODL_ask_face_data(object, &Type, Point, Dir, Box, Radius, RadData, &NormDir); 92 //UF_MODL_ask_face_edges(object, &edge_list); 93 //UF_MODL_ask_list_count(edge_list, &edge_count); 94 95 //tag_t edge_tag = NULL_TAG; 96 //UF_MODL_ask_list_item(edge_list, 1, &edge_tag); 97 //double point1[3]; 98 //double point2[3]; 99 //UF_MODL_ask_edge_verts(edge_tag, point1, point2, &vertex_count); 100 101 102 if (object == NULL) 103 { 104 return UF_UI_SEL_REJECT; 105 } 106 /*else if (object&&edge_count == 2 && Type == UF_cone_subtype && vertex_count <= 0)*/ 107 else if (object) 108 { 109 return UF_UI_SEL_ACCEPT; 110 } 111 } 112 113 static int init_proc(UF_UI_selection_p_t select, void* user_data) 114 { 115 int num_triples = 1;//可选类型的数量 116 117 UF_UI_mask_t mask_triples[] = 118 {UF_solid_type, UF_UI_SEL_NOT_A_FEATURE };//可选对象类型 119 UF_UI_set_sel_mask(select, UF_UI_SEL_MASK_CLEAR_AND_ENABLE_SPECIFIC, num_triples, mask_triples); 120 if ((UF_UI_set_sel_procs(select, select_filter_proc_fn, NULL, user_data)) == 0) 121 { 122 return UF_UI_SEL_SUCCESS; 123 } 124 else 125 { 126 return UF_UI_SEL_FAILURE; 127 } 128 } 129 130 131 132 extern "C" DllExport void ufusr(char *param, int *retCode, int paramLen) 133 { 134 UF_initialize(); 135 char sCue[] = "象选择对话框"; 136 char sTitle[] = "象选择对话框"; 137 int iScope = UF_UI_SEL_SCOPE_NO_CHANGE; 138 int iResponse; 139 tag_t *tObject; 140 int count = 0; 141 UF_UI_select_with_class_dialog(sCue, sTitle, iScope, init_proc, NULL, &iResponse, &count, &tObject); 142 if (count) 143 { 144 uf_list_p_t bodylist=NULL; 145 UF_MODL_create_list(&bodylist); 146 for (size_t i = 0; i < count; i++) 147 { 148 149 int opt = 1; //1=在同一个曲面上,2=转换为B曲面 150 tag_t face_tags = NULL_TAG; //如果第一个参数是2需要输入 151 tag_t result_tag = NULL_TAG; //返回特征 152 UF_MODL_edit_face_join(opt, tObject[i], &face_tags, &result_tag); 153 UF_DISP_set_highlight(tObject[i], 0); 154 UF_MODL_put_list_item(bodylist, tObject[i]); 155 } 156 UF_CALL(UF_MODL_delete_body_parms(bodylist)); 157 UF_CALL(UF_MODL_delete_list(&bodylist)); 158 } 159 else 160 { 161 return; 162 } 163 164 }