C#:通用方法总结—第8集

大家好,今天继续讲解我们的通用方法系列。

下面是今天分享的通用方法:

(1)这个通用方法为Ug删除参数构建器方法:

public static int RemoveParameters(int id)//删除参数构建器

    {

        UFSession.GetUFSession().Undo.SetMark(0, null, out id);

        BodyCollection Bodies = theSession.Parts.Work.Bodies;

        Body[] body = Bodies.ToArray();

        NXOpen.Features.RemoveParametersBuilder removeParametersBuilder1;

        removeParametersBuilder1 = theSession.Parts.Work.Features.CreateRemoveParametersBuilder();

        theSession.UpdateManager.SetDefaultUpdateFailureAction(NXOpen.Update.FailureOption.AcceptAll);

        for (int t = 0; t < body.Length; t++)

        {

            removeParametersBuilder1.Objects.Add(body[t]);

        }

        try

        {

            NXOpen.NXObject nXObject1;

            nXObject1 = removeParametersBuilder1.Commit();

            removeParametersBuilder1.Destroy();

        }

        catch (Exception e)

        {

            theUI.NXMessageBox.Show("提示", NXOpen.NXMessageBox.DialogType.Information, e.Message.ToString());

            return 0;

        }

        return id;

    }

(2)这个通用方法为SW校验是否选中为圆柱面:

/// <summary>

        /// 圆柱面校验

        /// </summary>

        /// <param name="swModel"></param>

        /// <returns></returns>

        public int MesoporeVerify(ModelDoc2 swModel, SelectionMgr swSelMgr,ref Face2 face)

        {

            int result = 0;

            try

            {            

                Face2 swEnt1 = (Face2)swSelMgr.GetSelectedObject6(1, -1);

                face = swEnt1;

                if (swEnt1 != null)

                {

                    Surface surface = swEnt1.GetSurface();

                    if (!surface.IsCylinder())

                    {

                        result = -1;

                    }

                }

                else

                {

                    result = -1;

                }              

            }

            catch

            {

                result = -1;

            }

            return result;

        }

(3)这个通用方法为SW验证选中面是不是平面:

        /// <summary>

        /// 验证是不是平面

        /// </summary>

        /// <param name="swModel"></param>

        /// <param name="swSelMgr"></param>

        /// <param name="face2"></param>

        /// <returns></returns>

        public int VerifyPlan(ModelDoc2 swModel, SelectionMgr swSelMgr,ref Face2 face2)

        {

            int result = 0;

            try

            {

                Face2 swEnt1 = (Face2)swSelMgr.GetSelectedObject6(1, -1);

                face2 = swEnt1;

                if (swEnt1 != null)

                {

                    Surface surface = swEnt1.GetSurface();

                    if (!surface.IsPlane())

                    {

                        result = -1;

                    }

                }

                else

                {

                    result = -1;

                }

            }

            catch

            {

                result = -1;

            }

            return result;

        }

今天要介绍的就是这么多,我们下篇文章再见。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

喵桑さん

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

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

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

打赏作者

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

抵扣说明:

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

余额充值