Ejemplo n.º 1
0
        private Inventor.LineSegment GetLargestEdge(ref Inventor.Face FaceView)
        {
            int    length      = FaceView.Edges.Count;
            double LengthParam = 0;

            Inventor.LineSegment Segment = null;
            // Inventor.Curve2dEvaluator Curve2dEvaluator;

            Inventor.Edge Edge = FaceView.Edges[1];
            Edge.Evaluator.GetParamExtents(out double MinParam, out double MaxParam);
            Edge.Evaluator.GetLengthAtParam(MinParam, MaxParam, out double Max);
            Inventor.UnitVector Uy = mInvApplication.TransientGeometry.CreateUnitVector(0, 1, 0);
            for (int i = 1; i <= length; i++)
            {
                Edge = FaceView.Edges[i];
                Edge.Evaluator.GetParamExtents(out MinParam, out MaxParam);
                Edge.Evaluator.GetLengthAtParam(MinParam, MaxParam, out LengthParam);

                if (LengthParam >= Max)
                {
                    if (Edge.GeometryType == Inventor.CurveTypeEnum.kLineSegmentCurve)
                    {
                        Segment = Edge.Geometry;
                        if (Segment.Direction.IsPerpendicularTo(Uy))
                        {
                            //  MessageBox.Show("");
                        }
                    }
                }
            }
            return(Segment);
        }
Ejemplo n.º 2
0
        private Inventor.UnitVector GetLargestEdgeUnitVector(ref Inventor.Face FaceView)
        {
            int    length      = FaceView.Edges.Count;
            double LengthParam = 0;

            Inventor.LineSegment Segment = null;

            Inventor.Edge Edge = FaceView.Edges[1];
            Edge.Evaluator.GetParamExtents(out double MinParam, out double MaxParam);
            Edge.Evaluator.GetLengthAtParam(MinParam, MaxParam, out double Max);
            Inventor.UnitVector UnitVector  = mInvApplication.TransientGeometry.CreateUnitVector(0, 0, 0);
            Inventor.UnitVector UnitVectorY = mInvApplication.TransientGeometry.CreateUnitVector(0, 1, 0);
            Inventor.UnitVector UnitVectorX = mInvApplication.TransientGeometry.CreateUnitVector(1, 0, 0);

            for (int i = 1; i <= length; i++)
            {
                Edge = FaceView.Edges[i];
                if (Edge.GeometryType == Inventor.CurveTypeEnum.kLineSegmentCurve)
                {
                    Segment = Edge.Geometry;
                }
                if (Edge.GeometryType == Inventor.CurveTypeEnum.kLineSegmentCurve)
                {
                    Edge.Evaluator.GetParamExtents(out MinParam, out MaxParam);
                    Edge.Evaluator.GetLengthAtParam(MinParam, MaxParam, out LengthParam);

                    if (LengthParam > Max)
                    {
                        Segment = Edge.Geometry;
                        Max     = LengthParam;
                    }
                }
            }

            if (Segment != null)
            {
                if (Edge.GeometryType == Inventor.CurveTypeEnum.kLineSegmentCurve)
                {
                    if (Segment.Direction.IsParallelTo(UnitVectorY))
                    {
                        UnitVector = UnitVectorX;
                    }
                    else if (Segment.Direction.IsParallelTo(UnitVectorX))
                    {
                        UnitVector = UnitVectorY;
                    }
                    return(UnitVector);
                }
            }
            return(UnitVector);
        }