【NX二次开发】 删除面操作

录制修改封装删除面 DeleteFaces

 1 #include <uf_defs.h>
 2 #include <NXOpen/NXException.hxx>
 3 #include <NXOpen/Session.hxx>
 4 #include <NXOpen/BasePart.hxx>
 5 #include <NXOpen/Builder.hxx>
 6 #include <NXOpen/Expression.hxx>
 7 #include <NXOpen/ExpressionCollection.hxx>
 8 #include <NXOpen/Face.hxx>
 9 #include <NXOpen/FaceDumbRule.hxx>
10 #include <NXOpen/Features_Brep.hxx>
11 #include <NXOpen/Features_DeleteFaceBuilder.hxx>
12 #include <NXOpen/Features_FeatureCollection.hxx>
13 #include <NXOpen/ISurface.hxx>
14 #include <NXOpen/NXObject.hxx>
15 #include <NXOpen/Part.hxx>
16 #include <NXOpen/PartCollection.hxx>
17 #include <NXOpen/Plane.hxx>
18 #include <NXOpen/PlaneCollection.hxx>
19 #include <NXOpen/ScCollector.hxx>
20 #include <NXOpen/ScRuleFactory.hxx>
21 #include <NXOpen/SelectISurface.hxx>
22 #include <NXOpen/SelectObject.hxx>
23 #include <NXOpen/SelectionIntentRule.hxx>
24 #include <NXOpen/Session.hxx>
25 #include <NXOpen/SmartObject.hxx>
26 #include <NXOpen/TaggedObject.hxx>
27 #include <NXOpen/Unit.hxx>
View Code
 1 static void DeleteFaces(vector<tag_t> tagFaces)
 2 {
 3     if (tagFaces.size() == 0) return;
 4     vector<Face *> deleteface;
 5     for (int i = 0; i < tagFaces.size(); i++)
 6     {
 7         NXOpen::Face *face1(dynamic_cast<NXOpen::Face *>(NXOpen::NXObjectManager::Get(tagFaces[i])));
 8         deleteface.push_back(face1);
 9     }
10 
11     Session *theSession = Session::GetSession();
12     Part *workPart(theSession->Parts()->Work());
13     Features::Feature *nullFeatures_Feature(NULL);
14     Features::DeleteFaceBuilder *deleteFaceB;
15     deleteFaceB = workPart->Features()->CreateDeleteFaceBuilder(nullFeatures_Feature);
16     FaceDumbRule *faceDumbRule1;
17     faceDumbRule1 = workPart->ScRuleFactory()->CreateRuleFaceDumb(deleteface);
18     std::vector<SelectionIntentRule *> rules1(1);
19     rules1[0] = faceDumbRule1;
20     deleteFaceB->FaceCollector()->ReplaceRules(rules1, false);
21     NXObject *nXObject1;
22     nXObject1 = deleteFaceB->Commit();
23     deleteFaceB->Destroy();
24 }

 

posted @ 2020-07-24 18:44  王牌飞行员_里海  阅读(481)  评论(0编辑  收藏  举报