Ejemplo n.º 1
0
        public static List <string> createSketchLavorazione(PartDocument oDoc, IDictionary <Face, List <Lavorazione> > lavorazione)
        {
            SheetMetalComponentDefinition oCompDef = (SheetMetalComponentDefinition)oDoc.ComponentDefinition;

            List <string> result = new List <string>();

            int index = 1;

            foreach (var x in lavorazione)
            {
                Face oFace = x.Key;
                List <Lavorazione> lavList = x.Value;

                foreach (Lavorazione lav in lavList)
                {
                    PlanarSketch oSketch = oCompDef.Sketches.Add(oFace, false);

                    foreach (Edge oEdge in lav.oEdgeColl_)
                    {
                        oSketch.AddByProjectingEntity(oEdge);
                        oSketch.Visible = false;
                    }

                    string nameSketch = lav.nameLav_ + "_" + index;
                    oSketch.Name = nameSketch;
                    result.Add(nameSketch);

                    index++;
                }
            }

            return(result);
        }
Ejemplo n.º 2
0
        /////////////////////////////////////////////////////////////
        // Use: Inserts new sketch in part and copies content
        //      from input sketch
        /////////////////////////////////////////////////////////////
        public static PlanarSketch InsertSketch(PartDocument doc,
                                                PlanarSketch sketch,
                                                UnitVector xAxis,
                                                UnitVector yAxis,
                                                Point basePoint)
        {
            PartComponentDefinition compDef =
                doc.ComponentDefinition;

            WorkAxis wa1 = compDef.WorkAxes.AddFixed(
                basePoint, xAxis, _ConstructionWorkFeature);

            WorkAxis wa2 = compDef.WorkAxes.AddFixed(
                basePoint, yAxis, _ConstructionWorkFeature);

            WorkPlane wp = compDef.WorkPlanes.AddByTwoLines(
                wa1, wa2, _ConstructionWorkFeature);

            WorkPoint origin = compDef.WorkPoints.AddFixed(
                basePoint, _ConstructionWorkFeature);

            PlanarSketch newSketch =
                compDef.Sketches.AddWithOrientation(
                    wp, wa1, true, true, origin, false);

            sketch.CopyContentsTo(newSketch as Sketch);

            return(newSketch);
        }
Ejemplo n.º 3
0
        public static void createCutLavorazione(PartDocument oDoc, List <string> nomeSketch)
        {
            SheetMetalComponentDefinition oCompDef = (SheetMetalComponentDefinition)oDoc.ComponentDefinition;

            foreach (string nameS in nomeSketch)
            {
                try
                {
                    PlanarSketch oSketch = oCompDef.Sketches[nameS];

                    SheetMetalFeatures oSheetMetalFeatures = (SheetMetalFeatures)oCompDef.Features;

                    Profile oProfile = oSketch.Profiles.AddForSolid();

                    CutDefinition oCutDefinition = oSheetMetalFeatures.CutFeatures.CreateCutDefinition(oProfile);

                    //oCutDefinition.SetThroughAllExtent(PartFeatureExtentDirectionEnum.kNegativeExtentDirection);

                    CutFeature oCutFeature = oSheetMetalFeatures.CutFeatures.Add(oCutDefinition);
                }
                catch
                {
                    throw new Exception("Nome sketch non esiste: " + nameS);
                }
            }
        }
Ejemplo n.º 4
0
        public SketchOp(PartDocument doc)
        {
            this.doc = doc;
            if (doc.ActivatedObject is PlanarSketch)
            {
                ps  = doc.ActivatedObject as PlanarSketch;
                sl1 = addLine();
                sl2 = findLine(sl1);
                //sl2.Construction = true;
                SketchLine tmp = findLine(sl2);
//                 tmp.Construction = true;
//                 tmp = findLine(tmp);
//                 tmp.Construction = true;
                //addMidConsraint(sl);
                sl = addPerpendicular(sl1, sl2);

                //addMidConsraint(sl2);
                sl3 = addPerpendicular(sl2, sl1, sl);
                //ps.GeometricConstraints.AddCoincident(sl.EndSketchPoint as SketchEntity, sl3.EndSketchPoint as SketchEntity);

                //sp = ps.SketchPoints.Add(sl.Geometry.MidPoint);
                sp = addPoint(sl1, sl2);
                addDimConstr(sp, sl, Macros.StandardAddInServer.data.parX);
                addDimConstr(sp, sl3, Macros.StandardAddInServer.data.parY);
                addAttr(doc as Document, sl1, sp, tmp.Construction);
                //doc.Update();
            }
        }
Ejemplo n.º 5
0
        //Создание эл-та кручение
        public RevolveFeature Create_Revolve(PlanarSketch sketch, PartFeatureOperationEnum enumer)
        {
            Profile        profile = sketch.Profiles.AddForSolid();
            RevolveFeature revolve = partCompDef.Features.RevolveFeatures.AddFull(profile, center_line, enumer);

            return(revolve);
        }
Ejemplo n.º 6
0
        public override void CreateModule(ParameterBase Parameter)
        {
            parCylineDoor = Parameter as ParCylinderDoor;
            if (parCylineDoor == null)
            {
                return;
            }
            init();
            PartDocument            part    = InventorTool.CreatePart();
            PartComponentDefinition partDef = part.ComponentDefinition;
            PlanarSketch            osketch = partDef.Sketches.Add(partDef.WorkPlanes[3]);
            SketchEllipticalArc     Arc1    = osketch.SketchEllipticalArcs.Add(InventorTool.Origin, InventorTool.Left, parCylineDoor.DoorRadius, parCylineDoor.InRadius, 0, Math.PI / 2);
            SketchEllipticalArc     Arc2    = osketch.SketchEllipticalArcs.Add(InventorTool.Origin, InventorTool.Left, parCylineDoor.DoorRadius + parCylineDoor.Thickness, parCylineDoor.InRadius + parCylineDoor.Thickness, 0, Math.PI / 2);

            osketch.GeometricConstraints.AddConcentric((SketchEntity)Arc1, (SketchEntity)Arc2);
            SketchLine Line1 = osketch.SketchLines.AddByTwoPoints(Arc1.StartSketchPoint, Arc2.StartSketchPoint);
            SketchLine Line2 = osketch.SketchLines.AddByTwoPoints(Arc1.EndSketchPoint, Arc2.EndSketchPoint);

            osketch.GeometricConstraints.AddHorizontalAlign(Arc1.StartSketchPoint, Arc1.CenterSketchPoint);
            osketch.GeometricConstraints.AddVerticalAlign(Arc1.EndSketchPoint, Arc1.CenterSketchPoint);
            osketch.GeometricConstraints.AddHorizontal((SketchEntity)Line1);
            osketch.GeometricConstraints.AddVertical((SketchEntity)Line2);
            osketch.DimensionConstraints.AddEllipseRadius((SketchEntity)Arc1, true, InventorTool.TranGeo.CreatePoint2d(-parCylineDoor.DoorRadius / 2, 0));
            osketch.DimensionConstraints.AddEllipseRadius((SketchEntity)Arc1, false, InventorTool.TranGeo.CreatePoint2d(0, -parCylineDoor.InRadius / 2));

            Point2d p = InventorTool.TranGeo.CreatePoint2d((Line1.StartSketchPoint.Geometry.X + Line1.EndSketchPoint.Geometry.X) / 2 + 1, (Line1.StartSketchPoint.Geometry.Y + Line1.EndSketchPoint.Geometry.Y) / 2 + 1);

            osketch.DimensionConstraints.AddTwoPointDistance(Line1.StartSketchPoint, Line1.EndSketchPoint, DimensionOrientationEnum.kAlignedDim, p);
            Profile        profile = osketch.Profiles.AddForSolid();
            RevolveFeature revolve = partDef.Features.RevolveFeatures.AddFull(profile, Line1, PartFeatureOperationEnum.kNewBodyOperation);
        }
Ejemplo n.º 7
0
        private void triangleSticker(ref PartDocument pDoc, double heigth, double width, string txt = "", double thickness = 0.01)
        {
            PartComponentDefinition compDef = pDoc.ComponentDefinition;
            PlanarSketch            ps      = compDef.Sketches.Add(compDef.WorkPlanes[3]);
            SketchLine line1 = ps.SketchLines.AddByTwoPoints(m_TG.CreatePoint2d(-width / 20, -heigth / 30), m_TG.CreatePoint2d(width / 20, -heigth / 30));
            SketchLine line2 = ps.SketchLines.AddByTwoPoints(line1.StartSketchPoint, m_TG.CreatePoint2d(0, heigth / 30 * 2));

            ps.SketchLines.AddByTwoPoints(line2.EndSketchPoint, line1.EndSketchPoint);
            Profile           pr     = ps.Profiles.AddForSolid();
            ExtrudeDefinition extDef = compDef.Features.ExtrudeFeatures.CreateExtrudeDefinition(pr, PartFeatureOperationEnum.kNewBodyOperation);

            extDef.SetDistanceExtent(thickness / 10, PartFeatureExtentDirectionEnum.kPositiveExtentDirection);
            ExtrudeFeature extr = compDef.Features.ExtrudeFeatures.Add(extDef);

            extr.Appearance = InvDoc.u.createColor(pDoc, "red_", "красный_", 255, 0, 0);
            if (txt != "")
            {
                ps = compDef.Sketches.Add(extr.EndFaces[1]);
                Inventor.TextBox tb = ps.TextBoxes.AddFitted(m_TG.CreatePoint2d(), txt);
                tb.HorizontalJustification = HorizontalTextAlignmentEnum.kAlignTextCenter;
                tb.VerticalJustification   = VerticalTextAlignmentEnum.kAlignTextMiddle;
                tb.SingleLineText          = false;
                //tb.Rotation = Math.PI;
                if (mirror)
                {
                    tb.Rotation = Math.PI;
                }
                EmbossFeature emb = compDef.Features.EmbossFeatures.AddEmbossFromFace(ps.Profiles.AddForSolid(false, ps.TextBoxes), 0.0005, PartFeatureExtentDirectionEnum.kPositiveExtentDirection);
                emb.Appearance = InvDoc.u.createColor(pDoc, "black_", "черный_", 0, 0, 0);
            }
        }
Ejemplo n.º 8
0
        internal override void DrawGeom(TransientGeometry TG, ref PlanarSketch sketch, ref List <SketchLine> lines)
        {
            var pos = lines.FindIndex(x => x == SideLine);

            lines.RemoveAt(pos);
            pos += 1;
            sketch.SketchLines[pos].Delete();
            var length = Distance + Width;

            switch (Side)
            {
            case ('r'):
                var point = sketch.SketchLines[pos - 1].EndSketchPoint;
                var line  = sketch.SketchLines.AddByTwoPoints(point, TG.CreatePoint2d(point.Geometry.X + Distance, point.Geometry.Y));
                var line0 = sketch.SketchLines.AddByTwoPoints(line.EndSketchPoint, TG.CreatePoint2d(line.EndSketchPoint.Geometry.X, Radius));
                var line1 = sketch.SketchLines.AddByTwoPoints(line0.EndSketchPoint, TG.CreatePoint2d(line0.EndSketchPoint.Geometry.X + Width, line0.EndSketchPoint.Geometry.Y));
                var line2 = sketch.SketchLines.AddByTwoPoints(line1.EndSketchPoint, TG.CreatePoint2d(line.EndSketchPoint.Geometry.X + Width, line.EndSketchPoint.Geometry.Y));
                sketch.SketchLines.AddByTwoPoints(line2.EndSketchPoint, sketch.SketchLines[pos].StartSketchPoint);
                break;

            case ('l'):
                point = sketch.SketchLines[pos].StartSketchPoint;
                line  = sketch.SketchLines.AddByTwoPoints(sketch.SketchLines[pos - 1].EndSketchPoint, TG.CreatePoint2d(point.Geometry.X - length, point.Geometry.Y));
                line0 = sketch.SketchLines.AddByTwoPoints(line.EndSketchPoint, TG.CreatePoint2d(line.EndSketchPoint.Geometry.X, Radius));
                line1 = sketch.SketchLines.AddByTwoPoints(line0.EndSketchPoint, TG.CreatePoint2d(line0.EndSketchPoint.Geometry.X + Width, line0.EndSketchPoint.Geometry.Y));
                line2 = sketch.SketchLines.AddByTwoPoints(line1.EndSketchPoint, TG.CreatePoint2d(line.EndSketchPoint.Geometry.X + Width, line.EndSketchPoint.Geometry.Y));
                sketch.SketchLines.AddByTwoPoints(line2.EndSketchPoint, point);
                break;
            }
        }
Ejemplo n.º 9
0
        public void MoveSketch(double m_xOffset, double m_yOffset)
        {
            PartDocument oPartDoc;

            oPartDoc = (PartDocument)m_inventorApplication.ActiveEditObject;

            PartComponentDefinition oPartCompDef;

            oPartCompDef = oPartDoc.ComponentDefinition;

            PlanarSketch oSketch = oPartCompDef.Sketches["Footprint" + m_thisiFeature.Name];

            Vector2d ovector = m_inventorApplication.TransientGeometry.CreateVector2d(m_yOffset, m_xOffset);

            ObjectCollection oSketchObjects;

            oSketchObjects = m_inventorApplication.TransientObjects.CreateObjectCollection();


            foreach (SketchEntity oSketchEntity in oSketch.SketchEntities)
            {
                oSketchObjects.Add(oSketchEntity);
            }
            oSketch.MoveSketchObjects(oSketchObjects, ovector);
        }
Ejemplo n.º 10
0
        //Скетч внешнего кольца
        public PlanarSketch OutsideRing()
        {
            PlanarSketch sketch  = partCompDef.Sketches.Add(partCompDef.WorkPlanes[3]);
            SketchPoints points_ = sketch.SketchPoints;
            SketchArcs   arcs_   = sketch.SketchArcs;
            SketchLines  lines_  = sketch.SketchLines;

            points_.Add(transGeom.CreatePoint2d(0, D / 2));
            points_.Add(transGeom.CreatePoint2d(B / 2 - r, D / 2));
            points_.Add(transGeom.CreatePoint2d(B / 2 - r, D / 2 - r));
            points_.Add(transGeom.CreatePoint2d(B / 2, D / 2 - r));
            points_.Add(transGeom.CreatePoint2d(B / 2, D / 2 - r - 0.3 * D / 6.2));
            points_.Add(transGeom.CreatePoint2d(B / 2 - 0.1 * B / 2, D / 2 - r - 0.4 * D / 6.2));
            points_.Add(transGeom.CreatePoint2d(Dw / 2, (D / 2 - d / 2) / 2 + d / 2 + Dw / 2));
            points_.Add(transGeom.CreatePoint2d(-Dw / 2, (D / 2 - d / 2) / 2 + d / 2 + Dw / 2));
            lines_.AddByTwoPoints(points_[1], points_[2]);
            arcs_.AddByCenterStartEndPoint(points_[3], points_[2], points_[4], false);
            for (int i = 4; i < 6; i++)
            {
                lines_.AddByTwoPoints(points_[i], points_[i + 1]);
            }
            arcs_.AddByCenterStartEndPoint(transGeom.CreatePoint2d(0, 0), points_[8], points_[6], false);
            lines_[3].EndSketchPoint.Merge(arcs_[2].StartSketchPoint);
            lines_.AddByTwoPoints(arcs_[2].EndSketchPoint, points_[1]);
            center_line = sketch.SketchLines.AddByTwoPoints(transGeom.CreatePoint2d(-1, 0), transGeom.CreatePoint2d(1, 0));
            return(sketch);
        }
Ejemplo n.º 11
0
 public Elements(Document doc)
 {
     app = Macros.StandardAddInServer.m_inventorApplication;
     if (doc.DocumentType == DocumentTypeEnum.kPartDocumentObject)
     {
         Entity.doc = doc as PartDocument;
         ss         = Entity.doc.SelectSet;
         if (ss.Count != 1)
         {
             return;
         }
         //cen = ss[1] as SketchPoint;
         //colect = app.TransientObjects.CreateObjectCollection();
         //add(u.pathUtil(doc) + "\\AC700-53A.00.006 (Люк автомата).ipt");
         //to = cen.Parent as PlanarSketch;
         ps = ss[1] as PlanarSketch;
         if (ps.SketchEntities.Count < 3)
         {
             readXML(@"c:\WORK\Завесы\Модули\asm.xml");
         }
         else
         {
             createXML();
         }
     }
 }
Ejemplo n.º 12
0
        internal override void Create_BR(TransientGeometry TG, ref PlanarSketch sketch, EdgeCollection eColl, ref Face B_face, ref Face E_face, ref PartComponentDefinition partDef)
        {
            ChamferFeature chamf_Feature;

            switch (Side)
            {
            case ('r'):
                try
                {
                    eColl.Add(B_face.Edges[1]);
                }
                catch
                {
                    MessageBox.Show("Catch r");
                    //eColl.Add(B_face.Edges[2]);
                }
                chamf_Feature = partDef.Features.ChamferFeatures.AddUsingDistance(eColl, Distance);
                break;

            case ('l'):
                try
                {
                    eColl.Add(E_face.Edges[2]);
                }
                catch
                {
                    MessageBox.Show("Catch l");
                    //eColl.Add(E_face.Edges[1]);
                }
                chamf_Feature = partDef.Features.ChamferFeatures.AddUsingDistance(eColl, Distance);
                break;
            }
        }
Ejemplo n.º 13
0
        private void Feature3(int x, int y)
        {
            PartDocument oPartDoc = (PartDocument)_invApp.ActiveDocument;

            oPartDoc.UnitsOfMeasure.LengthUnits = Inventor.UnitsTypeEnum.kMillimeterLengthUnits;
            PartComponentDefinition oCompDef = default(PartComponentDefinition);

            oCompDef = oPartDoc.ComponentDefinition;

            PlanarSketch oSketch = default(PlanarSketch);

            oSketch = oCompDef.Sketches.Add(oCompDef.WorkPlanes[3]);
            oSketch.SketchCircles.AddByCenterRadius(_invApp.TransientGeometry.CreatePoint2d(0, 0), 6);
            oSketch.SketchCircles.AddByCenterRadius(_invApp.TransientGeometry.CreatePoint2d(0, 0), 17.5);

            Profile oProfile = default(Profile);

            oProfile = oSketch.Profiles.AddForSolid();

            ExtrudeDefinition oExtrudeDef = default(ExtrudeDefinition);

            oExtrudeDef = oCompDef.Features.ExtrudeFeatures.CreateExtrudeDefinition(oProfile, Inventor.PartFeatureOperationEnum.kJoinOperation);
            oExtrudeDef.SetDistanceExtent(3, Inventor.PartFeatureExtentDirectionEnum.kPositiveExtentDirection);

            ExtrudeFeature oExtrude = default(ExtrudeFeature);

            oExtrude = oCompDef.Features.ExtrudeFeatures.Add(oExtrudeDef);
        }
Ejemplo n.º 14
0
        private void ExtrudeSketch(int x, int y)
        {
            //PartDocument oPartDoc = default(PartDocument);
            //oPartDoc = (PartDocument)_invApp.Documents.Add(Inventor.DocumentTypeEnum.kPartDocumentObject,_invApp.FileManager.GetTemplateFile(Inventor.DocumentTypeEnum.kPartDocumentObject));
            PartDocument oPartDoc = (PartDocument)_invApp.ActiveDocument;

            PartComponentDefinition oCompDef = default(PartComponentDefinition);

            oCompDef = oPartDoc.ComponentDefinition;

            PlanarSketch oSketch = default(PlanarSketch);

            oSketch = oCompDef.Sketches.Add(oCompDef.WorkPlanes[1]);
            oSketch.SketchLines.AddAsTwoPointRectangle(_invApp.TransientGeometry.CreatePoint2d(-x, -y), _invApp.TransientGeometry.CreatePoint2d(x, y));

            Profile oProfile = default(Profile);

            oProfile = oSketch.Profiles.AddForSolid();

            ExtrudeDefinition oExtrudeDef = default(ExtrudeDefinition);

            oExtrudeDef = oCompDef.Features.ExtrudeFeatures.CreateExtrudeDefinition(oProfile, Inventor.PartFeatureOperationEnum.kJoinOperation);
            oExtrudeDef.SetDistanceExtent(5, Inventor.PartFeatureExtentDirectionEnum.kSymmetricExtentDirection);

            ExtrudeFeature oExtrude = default(ExtrudeFeature);

            oExtrude = oCompDef.Features.ExtrudeFeatures.Add(oExtrudeDef);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// 创建两点间距离约束
        /// </summary>
        /// <param name="osketch"></param>
        /// <param name="p1"></param>
        /// <param name="p2"></param>
        /// <param name="value"></param>
        void CreateTwoPointDistanceConstraint(PlanarSketch osketch, SketchPoint p1, SketchPoint p2, double value)
        {
            Point2d p = InventorTool.TranGeo.CreatePoint2d((p1.Geometry.X + p2.Geometry.X) / 2 + 1, (p1.Geometry.Y + p2.Geometry.Y) / 2 + 1);
            TwoPointDistanceDimConstraint Constraint1 = osketch.DimensionConstraints.AddTwoPointDistance(p1, p2, DimensionOrientationEnum.kAlignedDim, p);

            Constraint1.Parameter.Value = value;
        }
Ejemplo n.º 16
0
        public void AssemblyFeature()
        {
            AssemblyDocument            oAssDoc = (AssemblyDocument)_InvApplication.ActiveDocument;
            AssemblyComponentDefinition oAsmDef = oAssDoc.ComponentDefinition;

            // Create a sketch on the XY workplane.
            PlanarSketch oSketch = default(PlanarSketch);

            oSketch = oAsmDef.Sketches.Add(oAsmDef.WorkPlanes[3]);

            TransientGeometry oTG = default(TransientGeometry);

            oTG = _InvApplication.TransientGeometry;

            // Draw a rectangle.
            oSketch.SketchLines.AddAsTwoPointRectangle(oTG.CreatePoint2d(0.1, 0.1), oTG.CreatePoint2d(1, 0.5));
            // Create a profile
            Profile oProfile = default(Profile);

            oProfile = oSketch.Profiles.AddForSolid();

            // Create the extrusion.
            ExtrudeDefinition oExtrudeDef = default(ExtrudeDefinition);

            oExtrudeDef = oAsmDef.Features.ExtrudeFeatures.CreateExtrudeDefinition(oProfile, PartFeatureOperationEnum.kCutOperation);
            oExtrudeDef.SetDistanceExtent("2 cm", PartFeatureExtentDirectionEnum.kSymmetricExtentDirection);

            oAsmDef.Features.ExtrudeFeatures.Add(oExtrudeDef);
        }
Ejemplo n.º 17
0
        protected void ResetRectangle()
        {
            if (_mouseEvents != null)
            {
                _mouseEvents.OnMouseMove  -= _onMouseMove_Delegate;
                _onMouseMove_Delegate      = null;
                _mouseEvents.OnMouseClick -= _onMouseClick_Delegate;
                _onMouseClick_Delegate     = null;
                _mouseEvents = null;
            }

            _rectangleLines                        = null;
            _horizontalMidPointAlign               = null;
            _verticalMidPointAlign                 = null;
            _userInputEvents.OnContextMenu        -= _userInputEvents_OnContextMenuDelegate;
            _userInputEvents_OnContextMenuDelegate = null;
            _planarSketch  = null;
            _drawingSketch = null;
            _secondSelectedSketchEntity = null;
            _inferredOriginPoint        = null;
            _inferredFinalPositionPoint = null;
            _firstSelectedSketchEntity  = null;
            _pickedPoint2d                  = null;
            _pickedSketchPoint              = null;
            _rectangleOriginSketchPoint     = null;
            _rectangleCoordSet              = null;
            _rectanglePointCoords           = null;
            _rectangleInteractionGraphics   = null;
            _rectangleGraphicsColorSet      = null;
            _interactionEvents.OnTerminate -= _onTerminate_Delegate;
            _interactionEvents.Stop();
            _interactionEvents = null;
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Создание плоскости переносом плоскостей ZY, ZX, XY.
        /// </summary>
        /// <param name="n">Номер плоскости: 1 - ZY, 2 - ZX, 3 - XY</param>
        /// <param name="offset">Относительное смещение плоскости</param>
        public void MakeNewWorkingPlane(int n, double offset)
        {
            var mainPlane   = _partDef.WorkPlanes[2];
            var offsetPlane = _partDef.WorkPlanes.AddByPlaneAndOffset(mainPlane, offset / Index);

            _currentSketch = _partDef.Sketches.Add(offsetPlane);
        }
Ejemplo n.º 19
0
 internal override void DrawGeom(TransientGeometry TG, ref PlanarSketch sketch, ref List<SketchLine> lines)
 {
     try
     {
         _length = 0;
         for (int i = 0; i < index; i++)
         {
             _length += var_es._list[i].Length;
         }
         
         switch (Side)
         {
             case ('r'):
                 _length += var_es._list[index].Length;
                 sketch.SketchLines.AddAsTwoPointRectangle(TG.CreatePoint2d(_length - Distance - Width, Radius), TG.CreatePoint2d(_length - Distance, var_es._list[index].Radius));
                 break;
             case ('l'):
                 sketch.SketchLines.AddAsTwoPointRectangle(TG.CreatePoint2d(_length + Distance, Radius), TG.CreatePoint2d(_length + Distance + Width, var_es._list[index].Radius));
                 break;
         }
     }
     catch (Exception e1)
     {
         MessageBox.Show(e1.ToString());
     }
 }
Ejemplo n.º 20
0
        internal override void DrawGeom(TransientGeometry TG, ref PlanarSketch sketch, ref List <SketchLine> lines)
        {
            Hord = 2 * Math.Sqrt(Depth * (2 * Radius - Depth));
            //(2 * Math.Sqrt(Depth * (2 * Radius - Depth))) to calculate hord distance
            var length = Distance + Hord;

            _length = 0;
            for (int i = 0; i < index; i++)
            {
                _length += var_es._list[i].Length;
            }

            switch (Side)
            {
            case ('r'):
                _length += var_es._list[index].Length;
                var arc = sketch.SketchArcs.AddByThreePoints(TG.CreatePoint2d(_length - Distance + 0.5 * Hord, var_es._list[index].Radius), TG.CreatePoint2d(_length - Distance, var_es._list[index].Radius - Depth), TG.CreatePoint2d(_length - Distance - 0.5 * Hord, var_es._list[index].Radius));
                sketch.SketchLines.AddByTwoPoints(arc.EndSketchPoint, arc.StartSketchPoint);
                break;

            case ('l'):
                arc = sketch.SketchArcs.AddByThreePoints(TG.CreatePoint2d(_length + Distance - 0.5 * Hord, var_es._list[index].Radius), TG.CreatePoint2d(_length + Distance, var_es._list[index].Radius - Depth), TG.CreatePoint2d(_length + Distance + 0.5 * Hord, var_es._list[index].Radius));
                sketch.SketchLines.AddByTwoPoints(arc.EndSketchPoint, arc.StartSketchPoint);
                break;
            }
        }
Ejemplo n.º 21
0
        private void CreatePart_Click(object sender, EventArgs e)
        {
            if (inventor == null)
            {
                MessageBox.Show("No inventor instance detected", "error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            PartDocument doc = inventor.Documents.Add(DocumentTypeEnum.kPartDocumentObject, null, true) as PartDocument;

            doc.PropertySets["{F29F85E0-4FF9-1068-AB91-08002B27B3D9}"]["Author"].Value = "Vladyslav Romanchuk";

            //User-defined property
            doc.PropertySets["{D5CDD505-2E9C-101B-9397-08002B2CF9AE}"].Add("Parts R Us", "Supplier");
            PartComponentDefinition partDefinition = (PartComponentDefinition)doc.ComponentDefinition;

            // Create a 2D sketch on the X-Y plane.
            PlanarSketch      sketch1 = (PlanarSketch)partDefinition.Sketches.Add(partDefinition.WorkPlanes[3]);
            TransientGeometry tg      = inventor.TransientGeometry;

            Point2d[] points = new Point2d[5] {
                tg.CreatePoint2d(0, 0), tg.CreatePoint2d(0, 20), tg.CreatePoint2d(20, 20), tg.CreatePoint2d(20, -10), tg.CreatePoint2d(10, -10)
            };
            SketchLine[] lines = new SketchLine[5];
            lines[0] = sketch1.SketchLines.AddByTwoPoints(points[0], points[1]);
            for (int i = 1; i < lines.Length - 1; i++)
            {
                lines[i] = sketch1.SketchLines.AddByTwoPoints(lines[i - 1].EndSketchPoint, points[i + 1]);
            }
            sketch1.SketchArcs.AddByCenterStartEndPoint(tg.CreatePoint2d(10, 0), lines[3].EndSketchPoint, lines[0].StartSketchPoint, false);

            //Extrude
            Profile           profile           = sketch1.Profiles.AddForSolid();
            ExtrudeDefinition extrudeDefinition = partDefinition.Features.ExtrudeFeatures.CreateExtrudeDefinition(profile, PartFeatureOperationEnum.kNewBodyOperation);

            extrudeDefinition.SetDistanceExtent(6, PartFeatureExtentDirectionEnum.kSymmetricExtentDirection);
            ExtrudeFeature extrude = (ExtrudeFeature)partDefinition.Features.ExtrudeFeatures.Add(extrudeDefinition);

            //second scatch
            Face topCap = extrude.EndFaces[1];

            sketch1 = partDefinition.Sketches.Add(topCap, false);

            Point2d      center = sketch1.ModelToSketchSpace(tg.CreatePoint(2.5, 1.5, 1.5));
            SketchCircle Circle = sketch1.SketchCircles.AddByCenterRadius(center, 1);

            profile           = sketch1.Profiles.AddForSolid(true, null, null);
            extrudeDefinition = partDefinition.Features.ExtrudeFeatures.CreateExtrudeDefinition(profile, PartFeatureOperationEnum.kJoinOperation);
            extrudeDefinition.SetDistanceExtent(4, PartFeatureExtentDirectionEnum.kSymmetricExtentDirection);
            extrude = (ExtrudeFeature)partDefinition.Features.ExtrudeFeatures.Add(extrudeDefinition);
            Edges          cylinderEdges = extrude.SideFaces[1].Edges;
            EdgeCollection filletEdges   = inventor.TransientObjects.CreateEdgeCollection(null);

            //foreach (var el in cylinderEdges)
            //    filletEdges.Add(el);
            filletEdges.Add(cylinderEdges[2]);
            //adding fillet
            partDefinition.Features.FilletFeatures.AddSimple(filletEdges, 0.25, false, false, false, false, false, true);
            //doc.SaveAs("D:\\SaveTest2.ipt", false);
        }
Ejemplo n.º 22
0
        private Profile selectFromSketch()
        {
            CommandManager cmdMgr = ((Inventor.Application)m_PartDoc.Parent).CommandManager;

            ps   = (PlanarSketch)cmdMgr.Pick(SelectionFilterEnum.kAllPlanarEntities, "Выберите эскиз:");
            name = ps.Name;
            return(ps.Profiles.AddForSolid());
        }
Ejemplo n.º 23
0
        static public void project(SheetMetalComponentDefinition smcd, string name)
        {
            WorkPlane    wp = smcd.WorkPlanes["Шип_справа"];
            PlanarSketch ps = smcd.Sketches.Add(wp);

            ps.Name = name; ps.Visible = false;
            ps.ProjectedCuts.Add();
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Создание плоскости переносом плоскостей ZY, ZX, XY
        /// </summary>
        /// <param name="n">Номер плоскости: 1 - ZY, 2 - ZX, 3 - XY</param>
        /// <param name="offset">Относительное смещение плоскости</param>
        public void MakeNewWorkingPlane(int n, double offset)
        {
            var mainPlane   = _partDef.WorkPlanes[n];
            var offsetPlane = _partDef.WorkPlanes.AddByPlaneAndOffset(mainPlane, offset / divider);

            _currentSketch      = _partDef.Sketches.Add(offsetPlane);
            offsetPlane.Visible = false;
        }
Ejemplo n.º 25
0
        // create a feature
        private void createFeature()
        {
            PartDocument oDoc = mApp.Documents.Add(DocumentTypeEnum.kPartDocumentObject,
                                                   mApp.FileManager.GetTemplateFile(DocumentTypeEnum.kPartDocumentObject,
                                                                                    SystemOfMeasureEnum.kDefaultSystemOfMeasure,
                                                                                    DraftingStandardEnum.kDefault_DraftingStandard, null),
                                                   true) as PartDocument;

            // Get the XZ Plane
            WorkPlane oWorkPlane = oDoc.ComponentDefinition.WorkPlanes[2];

            PlanarSketch oSketch = oDoc.ComponentDefinition.Sketches.Add(oWorkPlane, false);

            TransientGeometry oTG = mApp.TransientGeometry;

            //Create some transient points used for defining the lines (see BRep Module)
            Point2d[] oPoints = new Point2d[5];

            oPoints[0] = oTG.CreatePoint2d(0, 0);
            oPoints[1] = oTG.CreatePoint2d(-10, 0);
            oPoints[2] = oTG.CreatePoint2d(-10, -10);
            oPoints[3] = oTG.CreatePoint2d(5, -10);
            oPoints[4] = oTG.CreatePoint2d(5, -5);

            //Add the sketchlines, coincident constraints will be created automatically
            //since the "Line.EndSketchPoint" are provided each time we create a new line
            SketchLine[] oLines = new SketchLine[5];

            oLines[0] = oSketch.SketchLines.AddByTwoPoints(oPoints[0], oPoints[1]);
            oLines[1] = oSketch.SketchLines.AddByTwoPoints(oLines[0].EndSketchPoint, oPoints[2]);
            oLines[2] = oSketch.SketchLines.AddByTwoPoints(oLines[1].EndSketchPoint, oPoints[3]);
            oLines[3] = oSketch.SketchLines.AddByTwoPoints(oLines[2].EndSketchPoint, oPoints[4]);

            oSketch.SketchArcs.AddByCenterStartEndPoint(oTG.CreatePoint2d(0, -5), oLines[3].EndSketchPoint, oLines[0].StartSketchPoint, true);

            //Create a profile for the extrusion, here no need to worry since there is only
            //a single profile that is possible
            Profile oProfile = oSketch.Profiles.AddForSolid(true, null, null);



            // Definition Way:
            PartComponentDefinition oPartDocDef = oDoc.ComponentDefinition;

            // get ExtrudeFeatures collection
            ExtrudeFeatures extrudes = oPartDocDef.Features.ExtrudeFeatures;

            // Create an extrude definition in the new surface body
            ExtrudeDefinition extrudeDef = extrudes.CreateExtrudeDefinition(oProfile, PartFeatureOperationEnum.kJoinOperation);

            // Modify the extent
            extrudeDef.SetDistanceExtent(1, PartFeatureExtentDirectionEnum.kPositiveExtentDirection);


            // Create the extrusion.
            ExtrudeFeature extrude = extrudes.Add(extrudeDef);
        }
Ejemplo n.º 26
0
        /// <summary>
        /// 偏移
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="osketch"></param>
        /// <param name="source"></param>
        /// <param name="distance"></param>
        /// <param name="Direction"></param>
        /// <returns></returns>
        private T offsetLine <T>(PlanarSketch osketch, T source, double distance, bool Direction)
        {
            ObjectCollection obj = InventorTool.Inventor.TransientObjects.CreateObjectCollection();

            obj.Add(source);
            SketchEntitiesEnumerator Entities = osketch.OffsetSketchEntitiesUsingDistance(obj, distance, Direction, true, true);

            return(InventorTool.GetFirstFromIEnumerator <T>(Entities.GetEnumerator()));
        }
Ejemplo n.º 27
0
        //function to draw shaft with all features
        public static void Shaft()
        {
            partDef = var_es.part_doc.ComponentDefinition;
            tg      = var_es.InventorApp.TransientGeometry;
            sketch  = partDef.Sketches.Add(partDef.WorkPlanes[3]);
            Edges   = default(EdgeCollection);
            Edges   = var_es.InventorApp.TransientObjects.CreateEdgeCollection();
            S_Face  = null;
            E_Face  = null;
            Side_F  = null;
            int i = 0, j = 1;

            foreach (var part in var_es.list)
            {
                S_Face = null;
                E_Face = null;
                var obj = part;
                if (obj != null)
                {
                    obj.Create_BR(tg, ref sketch, Edges, ref S_Face, ref E_Face, ref partDef);
                }
                try
                {
                    if (var_es.chamfer_list.Count != 0)
                    {
                        S_Face = obj.Start_face;
                        E_Face = obj.End_face;
                        if (part is Pol)
                        {
                            Side_F = obj.Side_faces;
                        }

                        Edges = var_es.InventorApp.TransientObjects.CreateEdgeCollection();
                        if (var_es.chamfer_list[i] != null)
                        {
                            Create feature = var_es.chamfer_list[i];
                            feature.Create_BR(tg, ref sketch, Edges, ref S_Face, ref E_Face, ref partDef);
                        }
                        Edges  = var_es.InventorApp.TransientObjects.CreateEdgeCollection();
                        S_Face = obj.Start_face;
                        E_Face = obj.End_face;
                        if (var_es.chamfer_list[j] != null)
                        {
                            Create feature = var_es.chamfer_list[j];
                            feature.Create_BR(tg, ref sketch, Edges, ref S_Face, ref E_Face, ref partDef);
                        }
                    }
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.ToString());
                }
                i += 2;
                j += 2;
            }
        }
Ejemplo n.º 28
0
        public static void Build(InventorAPI api, string formName)
        {
            PlanarSketch[]   sketch  = new PlanarSketch[4];
            Profile[]        profile = new Profile[4];
            SketchPoint[]    point   = new SketchPoint[4];
            SketchLine[]     line    = new SketchLine[4];
            RevolveFeature[] revolve = new RevolveFeature[4];
            // Создание цилиндра
            sketch[0]  = api.Sketch(api.GetCompDef().WorkPlanes[3]);
            point[0]   = api.Point(sketch[0], 0, 0);
            point[1]   = api.Point(sketch[0], 0, H / 10);
            point[2]   = api.Point(sketch[0], D1 / 10 / 2, H / 10);
            point[3]   = api.Point(sketch[0], D1 / 10 / 2, 0);
            line[0]    = api.Line(sketch[0], point[0], point[1]);
            line[1]    = api.Line(sketch[0], point[1], point[2]);
            line[2]    = api.Line(sketch[0], point[2], point[3]);
            line[3]    = api.Line(sketch[0], point[3], point[0]);
            profile[0] = api.Profile(sketch[0]);
            revolve[0] = api.Revolve(profile[0], line[0], 0);
            // Создание пружины
            sketch[1]  = api.Sketch(api.GetCompDef().WorkPlanes[3]);
            point[0]   = api.Point(sketch[1], D1 / 10 / 2, 0);
            point[1]   = api.Point(sketch[1], D / 10 / 2, 0);
            point[3]   = api.Point(sketch[1], D1 / 10 / 2, T / 10);
            line[0]    = api.Line(sketch[1], point[0], point[1]);
            line[1]    = api.Line(sketch[1], point[1], point[3]);
            line[2]    = api.Line(sketch[1], point[3], point[0]);
            profile[1] = api.Profile(sketch[1]);
            var coil = api.GetCompDef().Features.CoilFeatures.AddByPitchAndHeight(profile[1], api.GetCompDef().WorkAxes[2], H1 / 10, H2 / 10, PartFeatureOperationEnum.kJoinOperation, false, false, 0, false, 0, 0, true);

            // Верхняя граница пружины
            sketch[2]  = api.Sketch(api.GetCompDef().WorkPlanes[3]);
            point[0]   = api.Point(sketch[2], 0, H2 / 10);
            point[1]   = api.Point(sketch[2], 0, H2 / 10 + T / 10);
            point[2]   = api.Point(sketch[2], D / 10 / 2, H2 / 10 + T / 10);
            point[3]   = api.Point(sketch[2], D / 10 / 2, H2 / 10);
            line[0]    = api.Line(sketch[2], point[0], point[1]);
            line[1]    = api.Line(sketch[2], point[1], point[2]);
            line[2]    = api.Line(sketch[2], point[2], point[3]);
            line[3]    = api.Line(sketch[2], point[3], point[0]);
            profile[2] = api.Profile(sketch[2]);
            revolve[2] = api.Revolve(profile[2], line[0], 0);
            // Крепление
            sketch[3]  = api.Sketch(api.GetCompDef().WorkPlanes[3]);
            point[0]   = api.Point(sketch[3], 0, H3 / 10);
            point[1]   = api.Point(sketch[3], 0, H3 / 10 + A / 10);
            point[2]   = api.Point(sketch[3], D / 10 / 2, H3 / 10 + A / 10);
            point[3]   = api.Point(sketch[3], D / 10 / 2, H3 / 10);
            line[0]    = api.Line(sketch[3], point[0], point[1]);
            line[1]    = api.Line(sketch[3], point[1], point[2]);
            line[2]    = api.Line(sketch[3], point[2], point[3]);
            line[3]    = api.Line(sketch[3], point[3], point[0]);
            profile[3] = api.Profile(sketch[3]);
            revolve[3] = api.Revolve(profile[3], line[0], 0);
            System.Windows.Forms.MessageBox.Show(formName + " завершено.", formName);
        }
Ejemplo n.º 29
0
        static public ObjectCollection getPoints(PlanarSketch ps)
        {
            ObjectCollection col = I.COC();

            foreach (SketchPoint item in ps.SketchPoints)
            {
                col.Add(item);
            }
            return(col);
        }
Ejemplo n.º 30
0
        public override void CreateModule(ParameterBase Parameter)
        {
            parCylinder = Parameter as ParCylinder;
            if (parCylinder == null)
            {
                return;
            }
            init();


            PartDocument            part = InventorTool.CreatePart();
            PartComponentDefinition partDef = part.ComponentDefinition;
            PlanarSketch            osketch = partDef.Sketches.Add(partDef.WorkPlanes[3]);
            SketchEllipticalArc     Arc1, Arc2;
            SketchLine Line1, Line2;

            CreateLines(osketch, out Arc1, out Line1, parCylinder.CapRadius, parCylinder.InRadius, parCylinder.Length);

            //SketchLine line5= offsetLine<SketchLine>(osketch, Line1, 2, true);
            //SketchOffsetSpline arc5 = (SketchOffsetSpline)offsetLine(osketch, Arc1, 2, true);
            //SketchLine Line3 = osketch.SketchLines.AddByTwoPoints(Arc1.StartSketchPoint, arc5.StartSketchPoint);
            //SketchLine Line4 = osketch.SketchLines.AddByTwoPoints(Line1.EndSketchPoint, line5.EndSketchPoint);
            //osketch.GeometricConstraints.AddHorizontal((SketchEntity)Line3);
            //osketch.GeometricConstraints.AddVertical((SketchEntity)Line4);
            //osketch.GeometricConstraints.AddEqualLength(Line3, Line4);
            //osketch.DimensionConstraints.AddEllipseRadius((SketchEntity)Arc1, true, InventorTool.TranGeo.CreatePoint2d(-parCylinder.CapRadius / 2, 0));
            //osketch.DimensionConstraints.AddEllipseRadius((SketchEntity)Arc1, false, InventorTool.TranGeo.CreatePoint2d(0, -parCylinder.InRadius / 2));
            //Point2d p = InventorTool.TranGeo.CreatePoint2d((Line1.StartSketchPoint.Geometry.X + Line1.EndSketchPoint.Geometry.X) / 2, (Line1.StartSketchPoint.Geometry.Y + Line1.EndSketchPoint.Geometry.Y) / 2 + 1);
            //osketch.DimensionConstraints.AddTwoPointDistance(Line1.StartSketchPoint, Line1.EndSketchPoint, DimensionOrientationEnum.kAlignedDim, p);
            //p = InventorTool.TranGeo.CreatePoint2d((Line4.StartSketchPoint.Geometry.X + Line4.EndSketchPoint.Geometry.X) / 2 + 1, (Line4.StartSketchPoint.Geometry.Y + Line4.EndSketchPoint.Geometry.Y) / 2);
            //osketch.DimensionConstraints.AddTwoPointDistance(Line4.StartSketchPoint, Line4.EndSketchPoint, DimensionOrientationEnum.kAlignedDim, p);

            CreateLines(osketch, out Arc2, out Line2, parCylinder.CapRadius + parCylinder.Thickness, parCylinder.InRadius + parCylinder.Thickness, parCylinder.Length);
            SketchLine Line3 = osketch.SketchLines.AddByTwoPoints(Arc1.StartSketchPoint, Arc2.StartSketchPoint);
            SketchLine Line4 = osketch.SketchLines.AddByTwoPoints(Line1.EndSketchPoint, Line2.EndSketchPoint);

            osketch.GeometricConstraints.AddHorizontalAlign(Arc1.StartSketchPoint, Arc1.CenterSketchPoint);
            osketch.GeometricConstraints.AddVerticalAlign(Arc1.EndSketchPoint, Arc1.CenterSketchPoint);
            osketch.GeometricConstraints.AddHorizontal((SketchEntity)Line3);
            osketch.GeometricConstraints.AddVertical((SketchEntity)Line4);
            osketch.GeometricConstraints.AddEqualLength(Line3, Line4);
            osketch.GeometricConstraints.AddConcentric((SketchEntity)Arc1, (SketchEntity)Arc2);
            // osketch.GeometricConstraints.AddCoincident((SketchEntity)InventorTool.Origin, (SketchEntity)Arc1.CenterSketchPoint);
            osketch.DimensionConstraints.AddEllipseRadius((SketchEntity)Arc1, true, InventorTool.TranGeo.CreatePoint2d(-parCylinder.CapRadius / 2, 0));
            osketch.DimensionConstraints.AddEllipseRadius((SketchEntity)Arc1, false, InventorTool.TranGeo.CreatePoint2d(0, -parCylinder.InRadius / 2));
            Point2d p = InventorTool.TranGeo.CreatePoint2d((Line1.StartSketchPoint.Geometry.X + Line1.EndSketchPoint.Geometry.X) / 2, (Line1.StartSketchPoint.Geometry.Y + Line1.EndSketchPoint.Geometry.Y) / 2 + 1);

            osketch.DimensionConstraints.AddTwoPointDistance(Line1.StartSketchPoint, Line1.EndSketchPoint, DimensionOrientationEnum.kAlignedDim, p);
            p = InventorTool.TranGeo.CreatePoint2d((Line4.StartSketchPoint.Geometry.X + Line4.EndSketchPoint.Geometry.X) / 2 + 1, (Line4.StartSketchPoint.Geometry.Y + Line4.EndSketchPoint.Geometry.Y) / 2);
            osketch.DimensionConstraints.AddTwoPointDistance(Line4.StartSketchPoint, Line4.EndSketchPoint, DimensionOrientationEnum.kAlignedDim, p);

            CreateRibs(osketch, Line2);
            Profile        profile = osketch.Profiles.AddForSolid();
            RevolveFeature revolve = partDef.Features.RevolveFeatures.AddFull(profile, Line3, PartFeatureOperationEnum.kNewBodyOperation);
        }
        /// <summary>
        /// When the user clicks on a point in the model, this method runs and creates an interaction graphics rectangle. 
        /// It also subscribes to the Mouse Move event to allow for the size of the rectangle to be driven by the location 
        /// of the mouse on the sketch. Ultimately, this method waits for the next click event, in which case it calls a 
        /// new method to actually create the sketched rectangle.  It has separate paths to react to whether it's a part
        /// sketch or a drawing sketch.
        /// </summary>
        /// <param name="button"></param>
        /// <param name="shiftKeys"></param>
        /// <param name="modelPosition"></param>
        /// <param name="viewPosition"></param>
        /// <param name="view"></param>
        protected void OnMouseClick_CreateRectangle(MouseButtonEnum button, ShiftStateEnum shiftKeys, Point modelPosition,
            Point2d viewPosition, Inventor.View view)
        {
            try
            {
                if (button == MouseButtonEnum.kLeftMouseButton)
                {
                    _onMouseMove_Delegate = new MouseEventsSink_OnMouseMoveEventHandler(OnMouseMove_DragCornerOfRectangle);
                    _mouseEvents.OnMouseClick -= _onMouseClick_Delegate;
                    _onMouseClick_Delegate = null;
                    _userInputEvents.OnContextMenu -= _userInputEvents_OnContextMenuDelegate;
                    _userInputEvents_OnContextMenuDelegate = null;

                    if (_inventorApplication.ActiveEditObject is PlanarSketch)
                    {
                        _planarSketch = (PlanarSketch)_inventorApplication.ActiveEditObject;

                        if (_mouseEvents.PointInferences.Count > 0)
                        {
                            _inferredOriginPoint = _mouseEvents.PointInferences[1];

                            switch (_inferredOriginPoint.InferenceType)
                            {
                                case PointInferenceEnum.kPtAtIntersection:
                                    _firstSelectedSketchEntity = (SketchEntity)_inferredOriginPoint.Entity[1];
                                    _firstInferredIntersectedSketchEntity = (SketchEntity)_inferredOriginPoint.Entity[2];
                                    break;
                                case PointInferenceEnum.kPtOnCurve:
                                    _firstSelectedSketchEntity = (SketchEntity)_inferredOriginPoint.Entity[1];
                                    break;
                                case PointInferenceEnum.kPtOnPt:
                                    _firstSelectedSketchEntity = (SketchPoint)_inferredOriginPoint.Entity[1];
                                    _pickedSketchPoint = (SketchPoint)_firstSelectedSketchEntity;
                                    _rectangleOriginSketchPoint = _pickedSketchPoint;
                                    break;
                                case PointInferenceEnum.kPtAtMidPoint:
                                    _firstSelectedSketchEntity = (SketchLine)_inferredOriginPoint.Entity[1];
                                    break;
                            }
                        }

                        _pickedPoint2d = _planarSketch.ModelToSketchSpace(modelPosition);

                        DrawInteractionRectangle();

                        _mouseEvents.OnMouseMove += _onMouseMove_Delegate;
                        _mouseEvents.MouseMoveEnabled = true;
                    }
                    else if (_inventorApplication.ActiveEditObject is DrawingSketch)
                    {
                        _drawingSketch = (DrawingSketch)_inventorApplication.ActiveEditObject;

                        if (_mouseEvents.PointInferences.Count > 0)
                        {
                            _inferredOriginPoint = _mouseEvents.PointInferences[1];

                            switch (_inferredOriginPoint.InferenceType)
                            {
                                case PointInferenceEnum.kPtAtIntersection:
                                    _firstSelectedSketchEntity = (SketchEntity)_inferredOriginPoint.Entity[1];
                                    _firstInferredIntersectedSketchEntity = (SketchEntity)_inferredOriginPoint.Entity[2];
                                    break;
                                case PointInferenceEnum.kPtOnCurve:
                                    _firstSelectedSketchEntity = (SketchEntity)_inferredOriginPoint.Entity[1];
                                    break;
                                case PointInferenceEnum.kPtOnPt:
                                    _firstSelectedSketchEntity = (SketchPoint)_inferredOriginPoint.Entity[1];
                                    _pickedSketchPoint = (SketchPoint)_firstSelectedSketchEntity;
                                    _rectangleOriginSketchPoint = _pickedSketchPoint;
                                    break;
                                case PointInferenceEnum.kPtAtMidPoint:
                                    _firstSelectedSketchEntity = (SketchLine)_inferredOriginPoint.Entity[1];
                                    break;
                            }
                        }
                        PointToPoint2d(modelPosition, out _pickedPoint2d);

                        DrawInteractionRectangle();

                        _mouseEvents.OnMouseMove += _onMouseMove_Delegate;
                        _mouseEvents.MouseMoveEnabled = true;
                    }
                    else
                        MessageBox.Show("You must be editing a sketch in order to use this tool.");
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }
        protected void ResetRectangle()
        {
            if (_mouseEvents != null)
            {
                _mouseEvents.OnMouseMove -= _onMouseMove_Delegate;
                _onMouseMove_Delegate = null;
                _mouseEvents.OnMouseClick -= _onMouseClick_Delegate;
                _onMouseClick_Delegate = null;
                _mouseEvents = null;
            }

            _rectangleLines = null;
            _horizontalMidPointAlign = null;
            _verticalMidPointAlign = null;
            _userInputEvents.OnContextMenu -= _userInputEvents_OnContextMenuDelegate;
            _userInputEvents_OnContextMenuDelegate = null;
            _planarSketch = null;
            _drawingSketch = null;
            _secondSelectedSketchEntity = null;
            _inferredOriginPoint = null;
            _inferredFinalPositionPoint = null;
            _firstSelectedSketchEntity = null;
            _pickedPoint2d = null;
            _pickedSketchPoint = null;
            _rectangleOriginSketchPoint = null;
            _rectangleCoordSet = null;
            _rectanglePointCoords = null;
            _rectangleInteractionGraphics = null;
            _rectangleGraphicsColorSet = null;
            _interactionEvents.OnTerminate -= _onTerminate_Delegate;
            _interactionEvents.Stop();
            _interactionEvents = null;
        }
Ejemplo n.º 33
0
        /// <summary>
        /// Создание плоскости переносом плоскостей ZY, ZX, XY
        /// </summary>
        /// <param name="n">Номер плоскости: 1 - ZY, 2 - ZX, 3 - XY</param>
        /// <param name="offset">Относительное смещение плоскости</param>
        public PlanarSketch MakeNewSketch(int n, double offset)
        {
            //Получаем ссылку на рабочую плоскость.
            var mainPlane = _partDef.WorkPlanes[n];

            //Делаем сдвинутую плоскость.
            var offsetPlane = _partDef.WorkPlanes.AddByPlaneAndOffset(mainPlane, offset / 10.0);

            //Создаем на плоскости скетч.
            _currentSketch = _partDef.Sketches.Add(offsetPlane);

            offsetPlane.Visible = false;

            return _currentSketch;
        }
Ejemplo n.º 34
0
 /// <summary>
 /// Создание плоскости переносом плоскостей ZY, ZX, XY
 /// </summary>
 /// <param name="n">Номер плоскости: 1 - ZY, 2 - ZX, 3 - XY</param>
 /// <param name="offset">Относительное смещение плоскости</param>
 public void MakeNewWorkingPlane(int n, double offset)
 {
     var mainPlane = _partDef.WorkPlanes[n];
     var offsetPlane = _partDef.WorkPlanes.AddByPlaneAndOffset(mainPlane, offset / divider);
     _currentSketch = _partDef.Sketches.Add(offsetPlane);
     offsetPlane.Visible = false;
 }