<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Making an extrude in ActiveDocument with Inventor api c# in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/making-an-extrude-in-activedocument-with-inventor-api-c/m-p/11519547#M144484</link>
    <description>&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;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?&lt;/SPAN&gt;&lt;/SPAN&gt; &lt;SPAN class=""&gt;&lt;SPAN class=""&gt;I want to cut an iam file with extrude that I have opened.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;  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);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 31 Oct 2022 07:29:37 GMT</pubDate>
    <dc:creator>hayattangercekler2</dc:creator>
    <dc:date>2022-10-31T07:29:37Z</dc:date>
    <item>
      <title>Making an extrude in ActiveDocument with Inventor api c#</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/making-an-extrude-in-activedocument-with-inventor-api-c/m-p/11519547#M144484</link>
      <description>&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;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?&lt;/SPAN&gt;&lt;/SPAN&gt; &lt;SPAN class=""&gt;&lt;SPAN class=""&gt;I want to cut an iam file with extrude that I have opened.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;  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);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 31 Oct 2022 07:29:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/making-an-extrude-in-activedocument-with-inventor-api-c/m-p/11519547#M144484</guid>
      <dc:creator>hayattangercekler2</dc:creator>
      <dc:date>2022-10-31T07:29:37Z</dc:date>
    </item>
    <item>
      <title>Re: Making an extrude in ActiveDocument with Inventor api c#</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/making-an-extrude-in-activedocument-with-inventor-api-c/m-p/11519787#M144487</link>
      <description>&lt;P&gt;The code you posted lacks of initialization of some fields and variables, maybe due to copy and paste from a bigger project from which this code was taken. Try to post&amp;nbsp; cleaner and easy to run code next time.&lt;BR /&gt;The issue could be the rectangle you're creating in the sketch: you cannot make a rectangle given two points on the same line (20, &lt;STRONG&gt;10&lt;/STRONG&gt;), (90, &lt;STRONG&gt;10&lt;/STRONG&gt;)&lt;/P&gt;</description>
      <pubDate>Mon, 31 Oct 2022 10:10:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/making-an-extrude-in-activedocument-with-inventor-api-c/m-p/11519787#M144487</guid>
      <dc:creator>CattabianiI</dc:creator>
      <dc:date>2022-10-31T10:10:29Z</dc:date>
    </item>
    <item>
      <title>Re: Making an extrude in ActiveDocument with Inventor api c#</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/making-an-extrude-in-activedocument-with-inventor-api-c/m-p/11519908#M144491</link>
      <description>&lt;P&gt;Thank you very much, you are the best. After looking at the codes again and changing their order and structure, I got the result I wanted. I had been working on it for a long time and this really pissed me off. There was no correct result from the answers of those who returned from the forum.&lt;BR /&gt;After all, I am sharing my correct working codes here.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;            string openIam = "C:\\Users\\username\\Documents\\Assembly1.iam";

            string fullpath1 = "C:\\Users\\username\\Desktop\\sampleIam\\partiam.iam";

            string fullpath2 = "C:\\Servers\\partiam.iam";

            var documentOpen = _application.Documents.Open(openIam, true);

  
            if (_application.ActiveDocument.DocumentType != DocumentTypeEnum.kAssemblyDocumentObject) return;

            documentOpen.UnitsOfMeasure.LengthUnits = UnitsTypeEnum.kMillimeterLengthUnits;

            AssemblyDocument StartDoc = _application.ActiveDocument as AssemblyDocument  ;

            var oSketch = _application.ActiveEditObject;

            var oAsmCompDef = StartDoc.ComponentDefinition;


            TransientGeometry transientGeometry = _application.TransientGeometry;



            Matrix matrix3 = transientGeometry.CreateMatrix();


            matrix3.SetTranslation(transientGeometry.CreateVector(0, 0, 0));

            ComponentOccurrence oOcc3;

            oOcc3 = oAsmCompDef.Occurrences.Add(fullpath1, matrix3);


            PlanarSketch osketch = oAsmCompDef.Sketches.Add(oAsmCompDef.WorkPlanes[3]);

            TransientGeometry transientgeo = _application.TransientGeometry;

            SketchEntitiesEnumerator objects = osketch.SketchLines.AddAsTwoPointRectangle(transientgeo.CreatePoint2d(20, 0), transientgeo.CreatePoint2d(95, 10));

            SketchLine sketchLine = objects[1] as SketchLine;

            double oneLine = sketchLine.Length;

            double copyLine = oneLine / 2;


            Profile oProfile = osketch.Profiles.AddForSolid();


            ExtrudeDefinition extrudeDefinition = oAsmCompDef.Features.ExtrudeFeatures.CreateExtrudeDefinition(oProfile, PartFeatureOperationEnum.kCutOperation);

            extrudeDefinition.SetDistanceExtent(42, PartFeatureExtentDirectionEnum.kSymmetricExtentDirection);

            var oExtrude = oAsmCompDef.Features.ExtrudeFeatures.Add(extrudeDefinition);


            int ipt1Xinput = Convert.ToInt16(ipt1xkonum.Text);

            int ipt2Xinput = int.Parse(ipt2xkonum.Text);

            int ipt1X = ipt1Xinput + 75;
            int ipt2X = ipt2Xinput + 75;

            Matrix matrix1 = transientGeometry.CreateMatrix();


            matrix1.SetTranslation(transientGeometry.CreateVector(ipt1X , 0, 0));



            string ipt1file = openFileDialog1.FileName;
            ComponentOccurrence oOcc1;
            oOcc1 = oAsmCompDef.Occurrences.Add(ipt1file , matrix1);

            Matrix matrix2 = transientGeometry.CreateMatrix();


            matrix1.SetTranslation(transientGeometry.CreateVector(ipt2X , 0, 0));

            string ipt2file = openFileDialog2.FileName;
            ComponentOccurrence oOcc2;
            oOcc2 = oAsmCompDef.Occurrences.Add(ipt2file , matrix2);


            

            StartDoc.SaveAs(fullpath2, false);&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 31 Oct 2022 11:21:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/making-an-extrude-in-activedocument-with-inventor-api-c/m-p/11519908#M144491</guid>
      <dc:creator>hayattangercekler2</dc:creator>
      <dc:date>2022-10-31T11:21:40Z</dc:date>
    </item>
    <item>
      <title>Re: Making an extrude in ActiveDocument with Inventor api c#</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/making-an-extrude-in-activedocument-with-inventor-api-c/m-p/11519941#M144492</link>
      <description>&lt;P&gt;Next time post the exception and the line throwing the exception you get running the code, too.&lt;/P&gt;</description>
      <pubDate>Mon, 31 Oct 2022 11:37:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/making-an-extrude-in-activedocument-with-inventor-api-c/m-p/11519941#M144492</guid>
      <dc:creator>CattabianiI</dc:creator>
      <dc:date>2022-10-31T11:37:54Z</dc:date>
    </item>
  </channel>
</rss>

