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

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

下面是今天要介绍的通用方法:

(1)这个通用方法为ug获取选择圆边的圆心

/// <summary>

    /// ug获取选择圆边的圆心

    /// </summary>

    /// <param name="a"></param>

    /// <returns></returns>

    public static double[] Getyuanxin(Tag a)//获取选择圆边的圆心

    {

        int type;

        theUFSession.Modl.AskEdgeType(a, out type);

        double[] p = new double[3];

        if (type == 3002)

        {

            IntPtr uFEval;

            theUFSession.Eval.Initialize(a, out uFEval);

            UFEval.Arc arc_coords;

            theUFSession.Eval.AskArc(uFEval, out arc_coords);

            p[0] = arc_coords.center[0];

            p[1] = arc_coords.center[1];

            p[2] = arc_coords.center[2];

        }

        return p;

}

(2)这个通用方法为ug获取tag

/// <summary>

    /// ug获取tag

    /// </summary>

    /// <param name="b"></param>

    /// <returns></returns>

    public static Tag Getplan(Tag b)

    {

        Tag a=Tag.Null;

        Tag[] facelist = null;

        theUFSession.Modl.AskEdgeFaces(b, out facelist);

        for (int i = 0; i < facelist.Length; i++)

        {

            int type1;

            theUFSession.Modl.AskFaceType(facelist[i], out type1);

            if (type1 == 22)

            {

                a = facelist[i];

            }

        }

        return a;

    }

(3)这个通用方法为ug删除孔

/// <summary>

    /// ug删除孔

    /// </summary>

    /// <param name="b"></param>

    public static void Deletekong(Tag b)//删除孔

    {

        NXOpen.Part workPart = theSession.Parts.Work;

        Tag[] facelist = null;

        theUFSession.Modl.AskEdgeFaces(b, out facelist);

        for (int i = 0; i < facelist.Length; i++)

        {

            int type1;

            theUFSession.Modl.AskFaceType(facelist[i], out type1);

            if (type1 == 17 || type1 == 16)

            {

                NXOpen.Face face1 = (NXOpen.Face)NXObjectManager.Get(facelist[i]);

                NXOpen.FaceBossPocketFacesRule faceBossPocketFacesRule1;

                faceBossPocketFacesRule1 = workPart.ScRuleFactory.CreateRuleFaceBossPocket(face1);

                NXOpen.SelectionIntentRule[] rules1 = new SelectionIntentRule[1];

                rules1[0] = faceBossPocketFacesRule1;

                NXOpen.ScCollector scCollector1 = workPart.ScCollectors.CreateCollector();

                scCollector1.ReplaceRules(rules1, false);

                TaggedObject[] BB = new TaggedObject[scCollector1.GetObjects().Length];

                BB = scCollector1.GetObjects();

                Face[] faces = new Face[0];

                foreach (var to in BB)

                {

                    Array.Resize(ref faces, faces.Length + 1);

                    faces[faces.Length - 1] = (Face)to;

                }

                DeleteFace(faces);

            }          

        }​​​​​​​

    }

今天要介绍的通用方法就这些,我们下篇文章再见。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

喵桑さん

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

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

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

打赏作者

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

抵扣说明:

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

余额充值