UG二次开发 抽壳功能实现

使用抽壳命令可挖空实体,或通过指定壁厚来绕实体创建壳。也可以对面指派个体厚度或移除个体面。

本实例通过录制抽壳命令,实现了对抽壳功能的二次开发封装。

抽壳工具截图如下:

最终抽壳效果如下:

一、主程序

//抽壳 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;
}

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

MarcoPro

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值