コード例 #1
0
        /// <summary>
        /// 获取内边界
        /// </summary>
        /// <returns></returns>
        public List <BoundaryModel> GetHoleBoundary()
        {
            FaceLoopUtils.LoopList[] list   = FaceLoopUtils.AskFaceLoops(face.Tag);
            List <BoundaryModel>     models = new List <BoundaryModel>();

            foreach (FaceLoopUtils.LoopList loop in list)
            {
                if (loop.Type == 2)
                {
                    BoundaryModel model = new BoundaryModel();
                    List <Edge>   edges = GetLoopToEdge(loop);
                    double        zMax  = GetLoopMaxOfZ(edges);
                    model.BouudaryPt = new Point3d(0, 0, zMax);
                    model.Edges      = edges;
                    model.Types      = NXOpen.CAM.BoundarySet.BoundaryTypes.Closed;
                    model.PlaneTypes = NXOpen.CAM.BoundarySet.PlaneTypes.UserDefined;
                    if (UMathUtils.IsEqual(zMax, faceData.BoxMaxCorner.Z))
                    {
                        model.ToolSide = NXOpen.CAM.BoundarySet.ToolSideTypes.InsideOrLeft;
                    }
                    else
                    {
                        model.ToolSide = NXOpen.CAM.BoundarySet.ToolSideTypes.OutsideOrRight;
                    }
                    models.Add(model);
                }
            }
            return(models);
        }
コード例 #2
0
        /// <summary>
        ///判断是否是导套
        /// </summary>
        /// <returns></returns>
        public bool IsGuidePin()
        {
            Face face = this.Builder.CylFeater[0].CylinderFace[0].Data.Face;

            FaceLoopUtils.LoopList[] loopList = FaceLoopUtils.AskFaceLoops(face.Tag);
            string   err = "";
            Vector3d vec = new Vector3d(-this.Direction.X, -this.Direction.Y, -this.Direction.Z);

            if (loopList.Length != 2)
            {
                return(false);
            }
            foreach (FaceLoopUtils.LoopList lt in loopList)
            {
                if (lt.Type == 2 && lt.EdgeList.Length == 1)
                {
                    Edge edge = NXObjectManager.Get(lt.EdgeList[0]) as Edge;
                    if (edge.SolidEdgeType == Edge.EdgeType.Circular)

                    {
                        ArcEdgeData data = EdgeUtils.GetArcData(edge, ref err);
                        if (data.Radius >= 8 && UMathUtils.IsEqual(data.Angle, Math.PI * 2))
                        {
                            int count1 = TraceARay.AskTraceARay(this.Body, data.Center, vec);
                            int count2 = TraceARay.AskTraceARay(this.Body, data.Center, this.Direction);
                            if (count1 == 0 && count2 == 0)
                            {
                                return(true);
                            }
                        }
                    }
                }
            }
            return(false);
        }
コード例 #3
0
        /// <summary>
        /// 判断是否是螺栓
        /// </summary>
        /// <returns></returns>
        public bool IsBolt()
        {
            Face face = this.Builder.CylFeater[0].CylinderFace[0].Data.Face;

            FaceLoopUtils.LoopList[] loopList = FaceLoopUtils.AskFaceLoops(face.Tag);
            if (loopList.Length != 2)
            {
                return(false);
            }
            foreach (FaceLoopUtils.LoopList lt in loopList)
            {
                if (lt.Type == 2 && lt.EdgeList.Length == 6)
                {
                    return(true);
                }
            }
            return(false);
        }
コード例 #4
0
        /// <summary>
        /// 获得基准面
        /// </summary>
        /// <returns></returns>
        private FaceData GetDatumFace()
        {
            string er = AttributeUtils.GetAttrForString(analysisBody.AnaFaces[1].Face, "DatumFace");

            if (er.Equals("Datum", StringComparison.CurrentCultureIgnoreCase))
            {
                return(analysisBody.AnaFaces[1].Data);
            }
            foreach (AnalysisFaceSlopeAndDia fe in analysisBody.AnaFaces)
            {
                string da = AttributeUtils.GetAttrForString(fe.Face, "DatumFace");
                if (da.Equals("Datum", StringComparison.CurrentCultureIgnoreCase))
                {
                    return(fe.Data);
                }
            }
            FaceLoopUtils.LoopList[] loops = FaceLoopUtils.AskFaceLoops(analysisBody.AnaFaces[0].Face.Tag);
            foreach (FaceLoopUtils.LoopList lt in FaceLoopUtils.AskFaceLoops(analysisBody.AnaFaces[0].Face.Tag)) //找到竖直面
            {
                if (lt.Type == 2)
                {
                    Edge edg = NXObjectManager.Get(lt.EdgeList[0]) as Edge;
                    foreach (Face fe in edg.GetFaces())
                    {
                        if (!fe.Equals(analysisBody.AnaFaces[0].Face))
                        {
                            foreach (Edge eg in fe.GetEdges())
                            {
                                foreach (Face fc in eg.GetFaces())
                                {
                                    FaceData fd    = FaceUtils.AskFaceData(fc);
                                    double   angle = UMathUtils.Angle(fd.Dir, new Vector3d(0, 0, 1));
                                    if (UMathUtils.IsEqual(angle, 0))
                                    {
                                        return(fd);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(null);
        }
コード例 #5
0
 /// <summary>
 /// 获取外边界
 /// </summary>
 /// <param name="model">边界</param>
 /// <param name="blank">毛坯距离</param>
 public void GetPeripheralBoundary(out BoundaryModel model, out double blank)
 {
     blank = 0;
     model = new BoundaryModel();
     FaceLoopUtils.LoopList[] list = FaceLoopUtils.AskFaceLoops(face.Tag);
     foreach (FaceLoopUtils.LoopList loop in list)
     {
         if (loop.Type == 1)
         {
             List <Edge> edges = GetLoopToEdge(loop);
             double      tempZ = GetLoopMaxOfZ(edges);
             blank            = Math.Round(tempZ - faceData.BoxMaxCorner.Z, 4);
             model.BouudaryPt = new Point3d(0, 0, faceData.BoxMaxCorner.Z);
             model.ToolSide   = NXOpen.CAM.BoundarySet.ToolSideTypes.InsideOrLeft;
             model.Types      = NXOpen.CAM.BoundarySet.BoundaryTypes.Closed;
             model.PlaneTypes = NXOpen.CAM.BoundarySet.PlaneTypes.UserDefined;
             model.Edges      = edges;
         }
     }
 }
コード例 #6
0
        public bool IsBolt()
        {
            Face topFace = this.Builder.CylFeater[0].CylinderFace[0].Data.Face;

            FaceLoopUtils.LoopList[]      list = FaceLoopUtils.AskFaceLoops(topFace.Tag);
            List <FaceLoopUtils.LoopList> hole = new List <FaceLoopUtils.LoopList>();

            foreach (FaceLoopUtils.LoopList lt in list)
            {
                if (lt.Type == 2)
                {
                    hole.Add(lt);
                }
            }
            if (hole.Count == 1 && hole[0].EdgeList.Length == 5)
            {
                return(true);
            }
            return(false);
        }
コード例 #7
0
        /// <summary>
        /// 判断是否是圆环面
        /// </summary>
        /// <param name="face"></param>
        /// <param name="arcEdge"></param>
        /// <returns></returns>
        public static bool IsCircleAnnylus(Face face, out List <ArcEdgeData> arcEdge)
        {
            arcEdge = new List <ArcEdgeData>();
            FaceLoopUtils.LoopList[] loops = FaceLoopUtils.AskFaceLoops(face.Tag);
            List <ArcEdgeData>       arc   = new List <ArcEdgeData>();
            string err = "";

            foreach (FaceLoopUtils.LoopList lt in loops)
            {
                if (lt.Type == 1)
                {
                    foreach (Tag egTag in lt.EdgeList)
                    {
                        Edge ed = NXObjectManager.Get(egTag) as Edge;
                        if (ed.SolidEdgeType == Edge.EdgeType.Circular)
                        {
                            ArcEdgeData arcData = EdgeUtils.GetArcData(ed, ref err);
                            if (arcData.Angle >= Math.PI)
                            {
                                arc.Add(arcData);
                            }
                        }
                    }
                }
            }
            if (arc.Count == 0)
            {
                return(false);
            }
            else if (arc.Count == 1)
            {
                arcEdge.Add(arc[0]);
                return(true);
            }
            else
            {
                var temp = arc.GroupBy(a => a.Center);
                int cout = 0;
                foreach (var tp in temp)
                {
                    int tpCont = tp.Count();
                    if (cout < tpCont)
                    {
                        cout = tpCont;
                    }
                }
                if (cout == 1)
                {
                    double anlge = arc.Max(a => a.Angle);
                    arcEdge.Add(arc.Find(a => a.Angle == anlge));
                    return(true);
                }
                else
                {
                    foreach (var tp in temp)
                    {
                        int tpCont = tp.Count();
                        if (cout == tpCont)
                        {
                            arcEdge.AddRange(tp);
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }