一个会的不多的人

一个会的不多的人

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

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

(1)这个通用方法为TaggedObject转换为Face

Public void  ConvertTag()

{

TaggedObject[] GetSelectedObjects = face_select0.GetSelectedObjects();

                Face[] faces = new Face[0];

                foreach (var to in GetSelectedObjects)

                {

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

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

                }

}

(2)这个通用方法为UG获取面属性

Public void GetFaceAttr(Face faces)

{

for (int a = 0; a < faces.Length; a++)

                {

                    NXObject.AttributeInformation[] attributeInformation1 = faces[a].GetUserAttributes();

                    foreach (var ai in attributeInformation1)//遍历面属性

                    {

                        if (ai.Type == NXObject.AttributeType.String)//属性是string类型

                        {

                            if (ai.Title == "A")//属性名

                            {

                                string value= (ai.StringValue);

                            }

                        }

                    }

                }

}

(3)这个通用方法为 判断圆形边是不是封闭的

/// <summary>

    /// 判断圆形边是不是封闭的,返回的是bool值

    /// </summary>

    /// <param name="edgetag"></param>

    /// <returns></returns>

    bool judgecircle(Tag edgetag)//判断圆形边是不是封闭的,返回的是bool值

    {

        IntPtr uFEval1;

        theUfSession.Eval.Initialize(edgetag, out uFEval1);

        UFEval.Arc arc1;

        theUfSession.Eval.AskArc(uFEval1, out arc1);

        bool boolvar = false;

        if (arc1.is_periodic)//判断是否为整圆

        {

            double[] arccenter = new double[100];

            arccenter[0] = arc1.center[0];

            arccenter[1] = arc1.center[1];

            arccenter[2] = arc1.center[2];

            double[] arcxaxis = new double[100];

            arcxaxis[0] = arc1.x_axis[0];

            arcxaxis[1] = arc1.x_axis[1];

            arcxaxis[2] = arc1.x_axis[2];

            double[] arcyaxis = new double[100];

            arcyaxis[0] = arc1.y_axis[0];

            arcyaxis[1] = arc1.y_axis[1];

            arcyaxis[2] = arc1.y_axis[2];

            double[] arcR = new double[100];

            arcR[0] = arc1.radius;

            bool boolisarc;

            theUfSession.Eval.IsArc(uFEval1, out boolisarc);

            if (Math.Abs(arc1.limits[0]) < 0.001 && Math.Abs(arc1.limits[1] - 2 * Math.PI) < 0.001)

            {

                boolvar = true;

            }

            theUfSession.Eval.Free(uFEval1);

        }

        return boolvar;

    }

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

08-14 22:03