Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
hayattangercekler2
362 Views, 3 Replies

Making an extrude in ActiveDocument with Inventor api c#

I need to make an extrude in ActiveDocument with Inventor api c#. I try a lot, but it doesn't work. What is the reason for this? I want to cut an iam file with extrude that I have opened.

 

 

 

  Application application1 = (Inventor.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application");
            string openIam = "C:\\Users\\User\\Documents\\Assembly1.iam";




            string fullpath1 = "C:\\Users\\USER\\DesktoP\\part1.iam";
            string fullpath2 = "C:\\Servers\\part.iam";

            var documentOpen = _application.Documents.Open(openIam, true);

            documentOpen.UnitsOfMeasure.LengthUnits = UnitsTypeEnum.kMillimeterLengthUnits;
            var StartDoc = _application.ActiveDocument as AssemblyDocument ;


   
            AssemblyComponentDefinition oAsmCompDef = StartDoc.ComponentDefinition;




            TransientGeometry transientGeometry = _application.TransientGeometry;

            int inputIpt1X = Convert.ToInt16(kapi1xkonum.Text);

            int inputIpt2X = int.Parse(kapi2xkonum.Text);

            int kapi1X = inputIpt1X + 75;
            int kapi2X = inputIpt2X + 75;

            Matrix matrix1 = transientGeometry.CreateMatrix();

            
            matrix1.SetTranslation(transientGeometry.CreateVector(kapi1X, 0, 0));



            string kapi1 = openFileDialog1.FileName;
            ComponentOccurrence oOcc1;
            oOcc1 = oAsmCompDef.Occurrences.Add(kapi1, matrix1);

            Matrix matrix2 = transientGeometry.CreateMatrix();


            matrix1.SetTranslation(transientGeometry.CreateVector(kapi2X, 0, 0));

            string kapi2 = openFileDialog2.FileName;
            ComponentOccurrence oOcc2;
            oOcc2 = oAsmCompDef.Occurrences.Add(kapi2, matrix1);

 
            Matrix matrix3 = transientGeometry.CreateMatrix();


            matrix3.SetTranslation(transientGeometry.CreateVector(0, 0, 0));
            ComponentOccurrence oOcc3;
            oOcc3 = oAsmCompDef.Occurrences.Add(fullpath1, matrix2);

            PlanarSketch sktch = oAsmCompDef.Sketches.Add(oAsmCompDef.WorkPlanes["XY Plane"], true);

            Profile oProfile = sktch.Profiles.AddForSolid();

            var cornerPointOne = transientGeometry.CreatePoint2d(20, 10);
            var cornerPointTwo = transientGeometry.
                CreatePoint2d(90, 10);

            _currentSketch.SketchLines.
                AddAsTwoPointRectangle(cornerPointOne, cornerPointTwo);


            var extrudeDef = oAsmCompDef.Features.ExtrudeFeatures.
                CreateExtrudeDefinition(oProfile,
                PartFeatureOperationEnum.kCutOperation);
            extrudeDef.SetDistanceExtent(42, PartFeatureExtentDirectionEnum.kPositiveExtentDirection);
            oAsmCompDef.Features.ExtrudeFeatures.Add(extrudeDef);


            StartDoc.SaveAs(fullpath2, false);

 

 

Tags (1)
Labels (2)