Пример #1
0
        /// <summary>
        /// 判断设定值是否正确
        /// </summary>
        /// <param name="ele"></param>
        /// <returns></returns>
        private bool IsSetValueOk()
        {
            Point pt = null;

            foreach (Point k in this.eleModel.PartTag.Points.ToArray())
            {
                if (k.Name.ToUpper().Equals(("SetValuePoint").ToUpper()))
                {
                    pt = k;
                }
            }
            if (pt == null)
            {
                return(false);
            }
            Tag     ptOccsTag = theUFSession.Assem.FindOccurrence(this.eleModel.GetPartComp(workPart).Tag, pt.Tag);
            Point   ptOcc     = NXObjectManager.Get(ptOccsTag) as Point;
            Point3d value     = ptOcc.Coordinates;
            Point3d eleSet    = new Point3d(this.eleModel.EleInfo.EleSetValue[0], this.eleModel.EleInfo.EleSetValue[1], this.eleModel.EleInfo.EleSetValue[2]);

            this.work.WorkMatr.ApplyPos(ref value);
            if (UMathUtils.IsEqual(value, eleSet))
            {
                return(true);
            }
            return(false);
        }
Пример #2
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);
        }
 public override void SetDimForFace(ref LinearDimension ld, Vector3d vec)
 {
     foreach (Face face in this.ToolingBox.GetBodies()[0].GetFaces())
     {
         if (face.SolidFaceType == Face.FaceType.Cylindrical)
         {
             Point3d  originPt = new Point3d(0, 0, 0);
             Vector3d normal   = new Vector3d(0, 0, 0);
             FaceUtils.AskFaceOriginAndNormal(face, out originPt, out normal);
             double angle1 = UMathUtils.Angle(vec, new Vector3d(1, 1, 1));
             if (UMathUtils.IsEqual(angle1, 0))
             {
                 ld.HandleOrientation = normal;
                 ld.HandleOrigin      = originPt;
             }
         }
         else
         {
             FaceData fd   = FaceUtils.AskFaceData(face);
             Vector3d temp = fd.Dir;
             this.Matr.ApplyVec(ref temp);
             double angle = UMathUtils.Angle(vec, temp);
             if (UMathUtils.IsEqual(angle, 0))
             {
                 ld.HandleOrientation = fd.Dir;
                 ld.HandleOrigin      = fd.Point;
             }
         }
     }
 }
Пример #4
0
        private void GetDowBaseModel()
        {
            List <MoldBaseModel> down = analysis.GetDownModel(this.moldbase);

            if (down.Count > 0)
            {
                if (down[down.Count - 1].DisPt.Z * 2 <= 10 && down.Count != 1)
                {
                    down.RemoveAt(down.Count - 1);
                }
                if (UMathUtils.IsEqual(down[0].CenterPt.Z + down[0].DisPt.Z, this.BMoldBase.CenterPt.Z - this.BMoldBase.DisPt.Z) &&
                    UMathUtils.IsEqual(down[0].CenterPt.X, 0) && UMathUtils.IsEqual(down[0].CenterPt.Y, 0))
                {
                    this.SupportPlate      = down[0];
                    this.SupportPlate.Name = "托板";
                }
                if (down.Count > 1)
                {
                    this.Baseplate      = down[down.Count - 1];
                    this.Baseplate.Name = "底板";
                }

                MoldBaseModel kon = this.analysis.GetKnockoutPlate(this.moldbase);
                if (kon != null)
                {
                    this.PushPlate      = kon;
                    this.PushPlate.Name = "推板";
                }
                List <MoldBaseModel> spa = this.analysis.GetSpacer(down); //方铁
                if (spa.Count > 0)
                {
                    this.Spacer.AddRange(spa);
                    List <MoldBaseModel> eiec = this.analysis.GetEiectorPlates(this.moldbase, spa);
                    if (eiec.Count != 0)
                    {
                        double max = eiec.Max(a => a.CenterPt.Z);
                        foreach (MoldBaseModel mm in eiec)
                        {
                            if (UMathUtils.IsEqual(mm.CenterPt.Z, max))
                            {
                                mm.Name = "面针板";
                                FaceEiectorPlates.Add(mm);
                            }
                            else
                            {
                                mm.Name = "底针板";
                                DowEiectorPlates.Add(mm);
                            }
                        }
                    }
                }
            }
            foreach (MoldBaseModel mm in down) //无名板
            {
                if (mm.Name == null || mm.Name.Equals(""))
                {
                    this.OtherBaseModel.Add(mm);
                }
            }
        }
Пример #5
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);
        }
Пример #6
0
        /// <summary>
        /// 设置颜色
        /// </summary>
        public void SetSlopeEqualColor()
        {
            foreach (AnalyzeFaceSlopeAndRadius ar in this.analyze)
            {
                if (UMathUtils.IsEqual(ar.MaxSlope, ar.MinSlope))
                {
                    if ((ar.MaxSlope < Math.Round(Math.PI / 2, 3) && ar.MaxSlope > 0) && ar.ResultsNum == 0)
                    {
                        SetColor(ar.face, 36);//斜度
                        continue;
                    }

                    if ((ar.MaxSlope == Math.Round(Math.PI / 2, 3)) && ar.ResultsNum == 0)
                    {
                        SetColor(ar.face, 211); //垂直
                        continue;
                    }
                    if ((UMathUtils.IsEqual(ar.MaxSlope, 0) || ar.MaxSlope == Math.Round(Math.PI, 3)) && ar.ResultsNum == 0)
                    {
                        SetColor(ar.face, 25); //平面
                        continue;
                    }
                }
                else if (!(ar.MaxSlope > Math.Round(Math.PI / 2, 3) && ar.MaxSlope <= Math.Round(Math.PI, 3)) && ar.ResultsNum > 0)
                {
                    SetColor(ar.face, 36);//斜度
                }
            }
        }
        /// <summary>
        /// 检查放电面积
        /// </summary>
        /// <param name="csys"></param>
        /// <param name="eleCt"></param>
        private void AskSetVaule(CartesianCoordinateSystem csys, ElectrodeSetValueInfo setValue, Component eleCt, ref List <string> err)
        {
            Part    elePart  = eleCt.Prototype as Part;
            Point3d setPoint = new Point3d(setValue.EleSetValue[0], setValue.EleSetValue[1], setValue.EleSetValue[2]);
            Point   pt       = GetSetPoint(elePart);

            if (pt == null)
            {
                err.Add(elePart.Name + "-" + setValue.Positioning + "               无法找到设定点!");
            }
            else if (!UMathUtils.IsEqual(setPoint, GetSetWorkPoint3d(pt, eleCt)))
            {
                err.Add(elePart.Name + "-" + setValue.Positioning + "                   设定值错误!");
            }
            Body     eleBody = GetOccsInBods(eleCt);
            BodyInfo info    = GetDischargeFace(csys, eleBody);

            if (info != null)
            {
                double newArea = info.GetProjectedArea(csys, work.Info.Matr);
                if (setValue.ProjectedArea >= 2 * newArea)
                {
                    setValue.ProjectedArea = newArea;
                    setValue.ContactArea   = info.ContactArea;
                    setValue.SetAttribute(eleCt);
                }
            }
        }
        /// <summary>
        /// 创建外形点
        /// </summary>
        /// <param name="centerPt"></param>
        /// <param name="disPt"></param>
        /// <returns></returns>
        public List <NXObject> CreatePoint()
        {
            UFSession theUFSession = UFSession.GetUFSession();

            if (UMathUtils.IsEqual(this.DisPt.X, 0) && UMathUtils.IsEqual(this.DisPt.Y, 0) && UMathUtils.IsEqual(this.DisPt.Z, 0))
            {
                return(null);
            }
            double[]        x      = { CenterPt.X - DisPt.X, CenterPt.X, CenterPt.X + DisPt.X };
            double[]        y      = { CenterPt.Y - DisPt.Y, CenterPt.Y, CenterPt.Y + DisPt.Y };
            double[]        z      = { CenterPt.Z - DisPt.Z, CenterPt.Z, CenterPt.Z + DisPt.Z };
            Matrix4         mat    = new Matrix4();
            List <NXObject> points = new List <NXObject>();

            mat.Identity();
            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    for (int k = 0; k < 3; k++)
                    {
                        Point3d temp = new Point3d(x[i], y[j], z[k]);
                        mat.ApplyPos(ref temp);
                        Tag pointTag = Tag.Null;
                        theUFSession.Curve.CreatePoint(new double[] { temp.X, temp.Y, temp.Z }, out pointTag);
                        theUFSession.Obj.SetColor(pointTag, 186);
                        points.Add(NXObjectManager.Get(pointTag) as NXObject);
                    }
                }
            }
            return(points);
        }
Пример #9
0
        /// <summary>
        /// 设置圆柱的属性点
        /// </summary>
        private void GetFacePoint()
        {
            Part      workPart = Session.GetSession().Parts.Work;
            Matrix3x3 mat3     = workPart.WCS.CoordinateSystem.Orientation.Element;
            Point3d   centerPt = new Point3d();
            Point3d   disPt    = new Point3d();
            Point3d   start    = new Point3d();
            Point3d   end      = new Point3d();
            Matrix4   inve     = this.Matr.GetInversMatrix();
            double    angleX   = UMathUtils.Angle(this.Direction, new Vector3d(mat3.Xx, mat3.Xy, mat3.Xz));
            double    angleY   = UMathUtils.Angle(this.Direction, new Vector3d(mat3.Yx, mat3.Yy, mat3.Yz));
            double    angleZ   = UMathUtils.Angle(this.Direction, new Vector3d(mat3.Zx, mat3.Zy, mat3.Zz));

            if ((UMathUtils.IsEqual(angleX, 0) || UMathUtils.IsEqual(angleX, Math.PI)) ||
                (UMathUtils.IsEqual(angleY, 0) || UMathUtils.IsEqual(angleY, Math.PI)) ||
                (UMathUtils.IsEqual(angleZ, 0) || UMathUtils.IsEqual(angleZ, Math.PI)))
            {
                this.GetCenterAndDisForData(out centerPt, out disPt);
            }
            else
            {
                this.GetFaceBoundingBox(out centerPt, out disPt);
            }
            start.Z = centerPt.Z - disPt.Z;
            end.Z   = centerPt.Z + disPt.Z;
            inve.ApplyPos(ref centerPt);
            inve.ApplyPos(ref start);
            inve.ApplyPos(ref end);
            this.CenterPt = centerPt;
            this.StartPt  = start;
            this.EndPt    = end;
            this.Length   = disPt.Z * 2;
        }
Пример #10
0
        protected bool IsPassThrough(AbstractCylinderBody ab, double start, double end)
        {
            double  anlge   = UMathUtils.Angle(analysis.Matr.GetZAxis(), ab.Direction);
            Point3d startPt = ab.StratPt;
            Point3d endPt   = ab.EndPt;

            this.analysis.Matr.ApplyPos(ref startPt);
            this.analysis.Matr.ApplyPos(ref endPt);

            if (UMathUtils.IsEqual(anlge, 0))
            {
                if (startPt.Z > start && endPt.Z < end)
                {
                    return(true);
                }
            }
            if (UMathUtils.IsEqual(anlge, Math.PI))
            {
                if (startPt.Z < start && endPt.Z > end)
                {
                    return(true);
                }
            }
            return(false);
        }
Пример #11
0
        /// <summary>
        /// 判断是否是一个孔
        /// </summary>
        /// <param name="other"></param>
        /// <returns></returns>
        public bool IsTheSameHole(AbstractCircleFace other)
        {
            double angle = UMathUtils.Angle(this.Data.Dir, other.Data.Dir);

            if (UMathUtils.IsEqual(angle, 0) == false && UMathUtils.IsEqual(angle, Math.PI) == false)
            {
                return(false);
            }
            Vector3d vec1 = new Vector3d();
            Vector3d vec2 = new Vector3d();

            if (UMathUtils.IsEqual(this.CenterPt, other.CenterPt))
            {
                vec1 = this.Data.Dir;
                vec2 = new Vector3d(-vec1.X, -vec1.Y, -vec1.Z);
            }
            else
            {
                vec1 = UMathUtils.GetVector(this.CenterPt, other.CenterPt);
                vec2 = UMathUtils.GetVector(other.CenterPt, this.CenterPt);
            }
            angle = UMathUtils.Angle(this.Data.Dir, vec1);
            if (UMathUtils.IsEqual(angle, 0) == false && UMathUtils.IsEqual(angle, Math.PI) == false)
            {
                return(false);
            }
            if (TraceARay.AskTraceARay(this.Data.Face.GetBody(), this.CenterPt, vec1) > 1 && TraceARay.AskTraceARay(other.Data.Face.GetBody(), other.CenterPt, vec2) > 1)

            {
                return(false);
            }
            return(true);
        }
Пример #12
0
        public override List <StandardPartsName> GetGuidePillar()
        {
            List <MoldBaseModel>        dowFace = this.FaceEiectorPlates.FindAll(a => a.CenterPt.Z < 0);
            List <MoldBaseModel>        dow     = this.DowEiectorPlates.FindAll(a => a.CenterPt.Z < 0);
            List <AbstractCylinderBody> pillars = new List <AbstractCylinderBody>();
            List <AbstractCylinderBody> pillar  = this.cylinderBody.FindAll(a => a.Radius >= 7 && a.IsGuidePillar());

            foreach (AbstractCylinderBody ab in pin)
            {
                AbstractCylinderBody pi = pillar.Find(a => UMathUtils.IsEqual(a.StratPt.X, ab.StratPt.X) && UMathUtils.IsEqual(a.StratPt.Y, ab.StratPt.Y));
                //if (!pillars.Exists(a => a.Equals(pi)))
                //{
                //    pillars.Add(pi);
                //}
                if (pi != null)
                {
                    pi.Name = "导柱";
                    pillars.Add(pi);
                    pillar.Remove(pi);
                }
            }
            if (this.SupportPlate != null && dowFace.Count != 0 && dow.Count != 0)
            {
                foreach (AbstractCylinderBody ab in pillar)
                {
                    Point3d start = ab.StratPt;
                    Point3d end   = ab.EndPt;
                    this.analysis.Matr.ApplyPos(ref start);
                    this.analysis.Matr.ApplyPos(ref end);
                    Vector3d vec = UMathUtils.GetVector(this.DowEiectorPlates[0].CenterPt, this.SupportPlate.CenterPt);
                    if (UMathUtils.IsEqual(UMathUtils.Angle(vec, ab.Direction), 0) &&
                        UMathUtils.IsEqual(start.Z, dow[0].CenterPt.Z + dow[0].DisPt.Z) &&
                        end.Z > this.SupportPlate.CenterPt.Z - this.SupportPlate.DisPt.Z)
                    {
                        ab.Name = "回针";
                        pillars.Add(ab);
                    }
                }
            }
            else if (this.SupportPlate == null && dowFace.Count != 0 && dow.Count != 0)
            {
                foreach (AbstractCylinderBody ab in pillar)
                {
                    Point3d start = ab.StratPt;
                    Point3d end   = ab.EndPt;
                    this.analysis.Matr.ApplyPos(ref start);
                    this.analysis.Matr.ApplyPos(ref end);
                    Vector3d vec = UMathUtils.GetVector(this.DowEiectorPlates[0].CenterPt, this.BMoldBase.CenterPt);
                    if (UMathUtils.IsEqual(UMathUtils.Angle(vec, ab.Direction), 0) &&
                        UMathUtils.IsEqual(start.Z, dow[0].CenterPt.Z + dow[0].DisPt.Z) &&
                        end.Z > this.BMoldBase.CenterPt.Z - this.BMoldBase.DisPt.Z)
                    {
                        ab.Name = "回针";
                        pillars.Add(ab);
                    }
                }
            }
            return(GetCyliderName(pillars));
        }
Пример #13
0
        /// <summary>
        /// 获取上模板
        /// </summary>
        protected override void GetUpBaseModel()
        {
            List <MoldBaseModel> up = analysis.GetUpModel(this.moldbase);

            if (up.Count > 0)
            {
                if (up[up.Count - 1].DisPt.Z <= 5 && up.Count != 1)
                {
                    up.RemoveAt(up.Count - 1);
                }
                if (up.Count == 1)
                {
                    this.UpBaseplate      = up[0];
                    this.UpBaseplate.Name = "水口板";
                }
                else
                {
                    if (UMathUtils.IsEqual(up[0].CenterPt.Z - up[0].DisPt.Z, this.AMoldBase.CenterPt.Z + this.AMoldBase.DisPt.Z))
                    {
                        this.ShuiSupportPlate      = up[0];
                        this.ShuiSupportPlate.Name = "水口推板";
                    }
                    this.UpBaseplate      = up[up.Count - 1];
                    this.UpBaseplate.Name = "水口板";
                }
                List <MoldBaseModel> spa = this.analysis.GetSpacer(up); //方铁
                if (spa.Count > 0)
                {
                    this.Spacer.AddRange(spa);
                    List <MoldBaseModel> eiec = this.analysis.GetEiectorPlates(this.moldbase, spa);
                    if (eiec.Count > 0)
                    {
                        double max = eiec.Max(a => a.CenterPt.Z);
                        foreach (MoldBaseModel mm in eiec)
                        {
                            if (UMathUtils.IsEqual(mm.CenterPt.Z, max))
                            {
                                mm.Name = "底针板";
                                DowEiectorPlates.Add(mm);
                            }
                            else
                            {
                                mm.Name = "面针板";
                                this.FaceEiectorPlates.Add(mm);
                            }
                        }
                    }
                }
            }
            foreach (MoldBaseModel mm in up) //无名板
            {
                if (mm.Name == null || mm.Name.Equals(""))
                {
                    this.OtherBaseModel.Add(mm);
                }
            }
        }
Пример #14
0
 public override int FaceColour()
 {
     if (UMathUtils.IsEqual(analy.MaxSlope, 0) && UMathUtils.IsEqual(analy.MaxSlope, analy.MinSlope))
     {
         return(25);
     }
     else
     {
         return(base.NextColour());
     }
 }
Пример #15
0
 public int CompareTo(BoundaryModel other)
 {
     if (!UMathUtils.IsEqual(this.CenterPt.X, other.CenterPt.X))
     {
         return(this.CenterPt.X.CompareTo(other.CenterPt.X));
     }
     else
     {
         return(this.CenterPt.Y.CompareTo(other.CenterPt.Y));
     }
 }
Пример #16
0
 public int CompareTo(ElectrodeToolhClassify other)
 {
     if (UMathUtils.IsEqual(this.X, other.X))
     {
         return(this.Y.CompareTo(other.Y));
     }
     else
     {
         return(this.X.CompareTo(other.X));
     }
 }
Пример #17
0
 public override string GetFaceType()
 {
     if (UMathUtils.IsEqual(analy.MaxSlope, 0) && UMathUtils.IsEqual(analy.MaxSlope, analy.MinSlope))
     {
         return("平面");
     }
     else
     {
         return(base.NextFacetype());
     }
 }
Пример #18
0
        /// <summary>
        /// 分析面
        /// </summary>
        /// <param name="face"></param>
        /// <param name="vec"></param>
        private void AnalyzeFace(Face face, Vector3d vec)
        {
            AnalyzeFaceSlopeAndRadius af = new AnalyzeFaceSlopeAndRadius(face);

            af.AnalyzeFace(vec);
            analyze.Add(af);
            if (Math.Abs(this.MinRadius) >= Math.Abs(af.MinRadius) && !UMathUtils.IsEqual(af.MinRadius, 0) &&
                UMathUtils.IsEqual(af.FaceData.IntNorm, -1))
            {
                this.MinRadius = af.MinRadius;
            }
        }
Пример #19
0
 /// <summary>
 /// 基准面设定属性
 /// </summary>
 /// <param name="body"></param>
 private void SetDatumAttr(Body body)
 {
     foreach (Face fe in body.GetFaces())
     {
         FaceData data = FaceUtils.AskFaceData(fe);
         if (UMathUtils.IsEqual(data.BoxMinCorner.Z, data.BoxMaxCorner.Z) &&
             UMathUtils.IsEqual(data.BoxMinCorner.Z, this.sketch.LeiLine[0].StartPoint.Z))
         {
             AttributeUtils.AttributeOperation("DatumFace", "Datum", fe);
         }
     }
 }
Пример #20
0
        /// <summary>
        /// 获取边
        /// </summary>
        /// <param name="xEdge"></param>
        /// <param name="yEdge"></param>
        public void GetEdge(out List <Edge> xEdge, out Point centerCom)
        {
            xEdge     = new List <Edge>();
            centerCom = null;
            string         str = "";
            ElectrodeModel ele = null;

            foreach (ElectrodeModel em in eleModels)
            {
                if (em.Info.AllInfo.SetValue.Positioning == "" || em.Info.AllInfo.SetValue.Positioning.Equals("A", StringComparison.CurrentCultureIgnoreCase))
                {
                    ele = em;
                }
            }
            if (ele == null)
            {
                return;
            }

            List <Face> faces = new List <Face>();

            faces.AddRange(ele.PartTag.Bodies.ToArray()[0].GetFaces());
            Point elePoint = ele.GetSetPoint();

            faces.Sort(delegate(Face a, Face b)
            {
                FaceData data1 = FaceUtils.AskFaceData(a);
                FaceData data2 = FaceUtils.AskFaceData(b);
                return(data1.Point.Z.CompareTo((data2.Point.Z)));
            });
            foreach (Component ct in AssmbliesUtils.GetPartComp(this.PartTag, ele.PartTag))
            {
                ElectrodeSetValueInfo value = ElectrodeSetValueInfo.GetAttribute(ct);
                if (value.Positioning == "" || value.Positioning.Equals("A", StringComparison.CurrentCultureIgnoreCase))
                {
                    centerCom = AssmbliesUtils.GetNXObjectOfOcc(ct.Tag, elePoint.Tag) as Point;
                    foreach (Edge eg in faces[10].GetEdges())
                    {
                        NXOpen.UF.UFEval.Line lineData;
                        if (EdgeUtils.GetLineData(eg, out lineData, ref str))
                        {
                            if (UMathUtils.IsEqual(lineData.start[1], lineData.end[1]))
                            {
                                xEdge.Add(AssmbliesUtils.GetNXObjectOfOcc(ct.Tag, eg.Tag) as Edge);
                            }
                        }
                    }
                }
            }
        }
Пример #21
0
        /// <summary>
        /// 获取垫脚
        /// </summary>
        /// <param name="molds"></param>
        /// <returns></returns>
        public List <MoldBaseModel> GetSpacer(List <MoldBaseModel> molds)
        {
            List <MoldBaseModel> spacer = new List <MoldBaseModel>();

            foreach (MoldBaseModel mm in molds)
            {
                if (!(UMathUtils.IsEqual(mm.CenterPt.X, 0) && UMathUtils.IsEqual(mm.CenterPt.Y, 0)))
                {
                    mm.Name = "方铁";
                    spacer.Add(mm);
                }
            }
            return(spacer);
        }
Пример #22
0
 public override void SetDimForFace(ref LinearDimension ld, Vector3d vec)
 {
     foreach (Face face in this.ToolingBox.GetBodies()[0].GetFaces())
     {
         FaceData fd   = FaceUtils.AskFaceData(face);
         Vector3d temp = fd.Dir;
         this.Matr.ApplyVec(ref temp);
         double angle = UMathUtils.Angle(vec, temp);
         if (UMathUtils.IsEqual(angle, 0))
         {
             ld.HandleOrientation = fd.Dir;
             ld.HandleOrigin      = fd.Point;
         }
     }
 }
Пример #23
0
        /// <summary>
        /// 获取平面边界
        /// </summary>
        /// <param name="analyzeFace"></param>
        /// <returns></returns>
        public List <Face> GetPlaneFaces()
        {
            List <Face> plane = new List <Face>();

            foreach (AnalyzeFaceSlopeAndRadius ar in builder.AnalyzeFaces)
            {
                if (UMathUtils.IsEqual(ar.MaxSlope, 0) && UMathUtils.IsEqual(ar.MinSlope, 0) && UMathUtils.IsEqual(GetFaceIsHighst(ar.face), 0))
                {
                    plane.Add(ar.face);
                }
            }
            // plane.Remove(this.BaseFace.Face);
            // plane.Remove(this.BaseSubfaceFace.Face);
            return(plane);
        }
Пример #24
0
        private static void SetMoveExpForNoDatum(double anlge)
        {
            Expression moveXExp = ExpressionUtils.CreateExp("moveX=0", "Number");
            Expression moveYExp = ExpressionUtils.CreateExp("moveY=0", "Number");

            ExpressionUtils.CreateExp("moveZ=0", "Number");
            ExpressionUtils.EditExp(moveXExp, "-(xNCopies-1)*xPitchDistance/2");
            if (UMathUtils.IsEqual(anlge, Math.PI))
            {
                ExpressionUtils.EditExp(moveYExp, "(yNCopies-1)*yPitchDistance/2");
            }
            else
            {
                ExpressionUtils.EditExp(moveYExp, "-(yNCopies-1)*yPitchDistance/2");
            }
        }
        /// <summary>
        /// 设置PICH控件显示
        /// </summary>
        private void SetPichContrShow()
        {
            double anleX = UMathUtils.Angle(this.model.Work.Matr.GetXAxis(), this.model.Vec);
            double anleY = UMathUtils.Angle(this.model.Work.Matr.GetYAxis(), this.model.Vec);

            if (UMathUtils.IsEqual(anleX, 0) || UMathUtils.IsEqual(anleX, Math.PI))
            {
                this.textBox_pitchX.Enabled    = false;
                this.textBox_pitchXNum.Enabled = false;
            }
            if (UMathUtils.IsEqual(anleY, 0) || UMathUtils.IsEqual(anleY, Math.PI))
            {
                this.textBox_pitchY.Enabled    = false;
                this.textBox_pitchYNum.Enabled = false;
            }
        }
        private List <BoundaryModel> GetBoundary()
        {
            List <BoundaryModel> models = new List <BoundaryModel>();

            foreach (Face face in Conditions)
            {
                PlanarBoundary pb = new PlanarBoundary(face);
                BoundaryModel  model1;
                double         blank1;
                pb.GetPeripheralBoundary(out model1, out blank1);
                if (UMathUtils.IsEqual(blank1, 0))
                {
                    models.Add(model1);
                }
            }
            return(models);
        }
Пример #27
0
        /// <summary>
        /// 圆形凸台
        /// </summary>
        /// <param name="other"></param>
        /// <returns></returns>
        public bool IsCircleStep(AbstractCircleFace other)
        {
            double angle = UMathUtils.Angle(this.Data.Dir, other.Data.Dir);

            if (UMathUtils.IsEqual(angle, 0) == false && UMathUtils.IsEqual(angle, Math.PI) == false)
            {
                return(false);
            }
            Vector3d vec1 = UMathUtils.GetVector(this.CenterPt, other.CenterPt);

            angle = UMathUtils.Angle(this.Data.Dir, vec1);
            if (UMathUtils.IsEqual(angle, 0) == false && UMathUtils.IsEqual(angle, Math.PI) == false)
            {
                return(false);
            }
            return(true);
        }
Пример #28
0
        public override void GetSlopeAndDia(Vector3d vec, out double[] slope, out double[] dia)
        {
            slope = new double[2];
            dia   = new double[2];
            double anlge = UMathUtils.Angle(vec, Data.Dir);

            dia[0] = dia[1] = 2 * Data.Radius;
            if (UMathUtils.IsEqual(anlge, 0) || UMathUtils.IsEqual(anlge, Math.PI))
            {
                slope[0] = slope[1] = Math.PI / 2;
            }
            else
            {
                double[] rid;
                FaceUtils.GetSweptSlope(this.Data.Face, vec, out slope, out rid);
            }
        }
Пример #29
0
        /// <summary>
        /// 向下搜索
        /// </summary>
        /// <param name="molds"></param>
        /// <param name="z"></param>
        /// <returns></returns>
        private List <MoldBaseModel> SeekDownMoldBaseModel(List <MoldBaseModel> molds, ref double minz)
        {
            List <MoldBaseModel> mb = new List <MoldBaseModel>();

            foreach (MoldBaseModel mm in molds)
            {
                double mmz = mm.CenterPt.Z + mm.DisPt.Z;
                if (UMathUtils.IsEqual(minz, mmz))
                {
                    mb.Add(mm);
                }
            }
            if (mb.Count > 0)
            {
                minz = mb[0].CenterPt.Z - mb[0].DisPt.Z;
            }
            return(mb);
        }
Пример #30
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);
        }