Esempio n. 1
0
        /// <summary>
        /// 求两个面的夹角
        /// </summary>
        /// <param name="face1"></param>
        /// <param name="face2"></param>
        /// <returns></returns>
        public static double Angle(Face face1, Face face2)
        {
            Vector3d vec1 = FaceUtils.AskFaceNormal(face1);
            Vector3d vec2 = FaceUtils.AskFaceNormal(face2);

            return(UMathUtils.Angle(vec1, vec2));
        }
Esempio n. 2
0
        /// <summary>
        /// 以面数据创建平面
        /// </summary>
        /// <param name="planeFace"></param>
        /// <returns></returns>
        public static NXOpen.Plane CreatePlaneOfFace(Face face, bool flip)
        {
            Part     workPart = theSession.Parts.Work;
            Point3d  originPt;
            Vector3d normal;

            FaceUtils.AskFaceOriginAndNormal(face, out originPt, out normal);
            NXOpen.Plane plane1 = workPart.Planes.CreatePlane(originPt, normal, NXOpen.SmartObject.UpdateOption.WithinModeling);
            plane1.SetFlip(flip);
            return(plane1);
        }
Esempio n. 3
0
        /// <summary>
        /// 获取面上的点
        /// </summary>
        /// <param name="face"></param>
        /// <returns></returns>
        private static Point3d GetFacePoint(Face face)
        {
            UFSession theUFSession = UFSession.GetUFSession();
            int       statusPt;

            double[] point;
            FaceData data = FaceUtils.AskFaceData(face);

            point = new double[3] {
                data.Point.X, data.Point.Y, data.Point.Z
            };
            theUFSession.Modl.AskPointContainment(point, face.Tag, out statusPt);
            if (statusPt == 1)
            {
                return(data.Point);
            }
            else
            {
                double[] uvs = new double[4];
                theUFSession.Modl.AskFaceUvMinmax(face.Tag, uvs); //获得面u,v参数空间(u,v最小,最大值)
                double[] param = new double[2];                   //输入U,V方向值

                for (int i = 1; i < 6; i++)
                {
                    param[0] = i * (uvs[1] - uvs[0]) / 5 + uvs[0];
                    param[1] = i * (uvs[3] - uvs[2]) / 5 + uvs[2];
                    double[] point1    = new double[3];    //输出点坐标
                    double[] u1        = new double[3];    //输出 输出一阶导数在U位置
                    double[] v1        = new double[3];    //输出 输出一阶导数在V位置
                    double[] u2        = new double[3];    //输出 输出二阶导数在U位置
                    double[] v2        = new double[3];    //输出 输出二阶导数在V位置
                    double[] unit_norm = new double[3];    //输出面上该点的矢量方向
                    double[] radii     = new double[2];    //输出,双半径,输出主曲率半径
                    theUFSession.Modl.AskFaceProps(face.Tag, param, point1, u1, v1, u2, v2, unit_norm, radii);
                    theUFSession.Modl.AskPointContainment(point1, face.Tag, out statusPt);
                    if (statusPt == 1)
                    {
                        return(new Point3d(point1[0], point1[1], point1[2]));
                    }
                }
            }
            return(new Point3d());
        }
Esempio n. 4
0
        /// <summary>
        /// 以面中心点和向量创建平面
        /// </summary>
        /// <param name="planeFace"></param>
        /// <param name="flip">设置是否翻转方向</param>
        /// <returns></returns>
        public static NXOpen.Plane CreatePlaneOfFace(Face face, bool flip)
        {
            Part     workPart = theSession.Parts.Work;
            Point3d  originPt;
            Vector3d normal;

            FaceUtils.AskFaceOriginAndNormal(face, out originPt, out normal);
            try
            {
                NXOpen.Plane plane1 = workPart.Planes.CreatePlane(originPt, normal, NXOpen.SmartObject.UpdateOption.WithinModeling);
                plane1.SetFlip(flip);
                return(plane1);
            }
            catch (NXException ex)
            {
                LogMgr.WriteLog("Basic.TrimBody:CreateTrimBodyFeature:" + ex.Message);
                throw ex;
            }
        }