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);
        }
Ejemplo n.º 3
0
        private void AddFlangeiMateDefinitions(ref Inventor.PartDocument PartDocument, string Dia, string MateNamePrefix, string Offset)
        {
            Inventor.ExtrudeFeature ExtrudeFeature;
            Inventor.UnitsOfMeasure UnitsOfMeasure;
            Inventor.Edge           Edge = null;
            Inventor.EdgeLoops      EdgeLoops;
            double FlangeHoleDiaOD = 0;
            int    Counter         = 0;

            ExtrudeFeature  = PartDocument.ComponentDefinition.Features.ExtrudeFeatures[1];
            UnitsOfMeasure  = PartDocument.UnitsOfMeasure;
            FlangeHoleDiaOD = UnitsOfMeasure.GetValueFromExpression(Dia, Inventor.UnitsTypeEnum.kMillimeterLengthUnits);

            foreach (Inventor.Face Face in ExtrudeFeature.Faces)
            {
                if (Face.SurfaceType == Inventor.SurfaceTypeEnum.kCylinderSurface)
                {
                    Inventor.Cylinder Cylinder;
                    Cylinder = Face.Geometry;
                    if (Cylinder.Radius == FlangeHoleDiaOD / 2)
                    {
                        EdgeLoops = Face.EdgeLoops;
                        foreach (Inventor.EdgeLoop EdgeLoop in EdgeLoops)
                        {
                            if (EdgeLoop.IsOuterEdgeLoop)
                            {
                                foreach (Inventor.Edge mEdge in EdgeLoop.Edges)
                                {
                                    if (mEdge.CurveType == Inventor.CurveTypeEnum.kCircleCurve)
                                    {
                                        Edge = mEdge;
                                        PartDocument.ComponentDefinition.iMateDefinitions.AddInsertiMateDefinition(Edge, false, Offset, null, MateNamePrefix + ":" + Counter.ToString());
                                        Counter++;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 4
0
        private void GetEdgeData(Inventor.Edge Edge)
        {
            Inventor.Curve2dEvaluator Curve2dEvaluator;
            double MinParam = 0;
            double MaxParam = 0;

            // double LengthParam = 0;
            double[] StartParams = new double[3];
            double[] EndParams   = new double[3];
            double[] mPoints     = new double[3];
            foreach (Inventor.EdgeUse EdgeUse in Edge.EdgeUses)
            {
                StartParams[0]   = MinParam;
                StartParams[1]   = 0;
                StartParams[2]   = 0;
                EndParams[0]     = MinParam;
                EndParams[1]     = 0;
                EndParams[2]     = 0;
                Curve2dEvaluator = EdgeUse.Evaluator;
                Curve2dEvaluator.GetParamExtents(out MinParam, out MaxParam);

                Curve2dEvaluator.GetPointAtParam(ref StartParams, ref mPoints);
            }
        }