使用抽壳命令可挖空实体,或通过指定壁厚来绕实体创建壳。也可以对面指派个体厚度或移除个体面。
本实例通过录制抽壳命令,实现了对抽壳功能的二次开发封装。
抽壳工具截图如下:
最终抽壳效果如下:
一、主程序
//抽壳 BLOCK(6)
theUFSession = UFSession.GetUFSession();
theSession = Session.GetSession();
workPart = theSession.Parts.Work;
Tag faceTag = Tag.Null;
theUFSession.Obj.CycleByName("FACE", ref faceTag);
Body body1 = (Body)workPart.Bodies.FindObject("BLOCK(1)");
EventHelper.CreateShellNXopen(body1.Tag, faceTag, "5");
二、抽壳方法封装
/// <summary>
/// 抽壳
/// </summary>
/// <param name="targetTag">抽壳对象</param>
/// <param name="faceTag">抽壳面</param>
/// <param name="thickness">抽壳厚度</param>
public static Tag CreateShellNXopen(Tag targetTag , Tag faceTag, string thickness)
{
theSession = Session.GetSession();
workPart = theSession.Parts.Work;
NXOpen.Features.Feature nullFeatures_Feature = null;
NXOpen.Features.ShellBuilder shellBuilder1;
shellBuilder1 = workPart.Features.CreateShellBuilder(nullFeatures_Feature);
shellBuilder1.Tolerance = 0.001;
shellBuilder1.UseSurfaceApproximation = true;
shellBuilder1.TgtPierceOption = false;
shellBuilder1.SetDefaultThickness(thickness);
ScCollector scCollector1;
scCollector1 = workPart.ScCollectors.CreateCollector();
Face face1 = (Face)NXOpen.Utilities.NXObjectManager.Get(faceTag);
Face[] boundaryFaces1 = new Face[0];
FaceTangentRule faceTangentRule1;
faceTangentRule1 = workPart.ScRuleFactory.CreateRuleFaceTangent(face1, boundaryFaces1, 0.05);
SelectionIntentRule[] rules1 = new SelectionIntentRule[1];
rules1[0] = faceTangentRule1;
scCollector1.ReplaceRules(rules1, false);
shellBuilder1.RemovedFacesCollector = scCollector1;
Body body1 = (Body)NXOpen.Utilities.NXObjectManager.Get(targetTag);
shellBuilder1.Body = body1;
NXObject nXObject1;
nXObject1 = shellBuilder1.Commit();
shellBuilder1.Destroy();
return nXObject1.Tag;
}