<?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 Exception while using circular pattern feature in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/exception-while-using-circular-pattern-feature/m-p/9855931#M117874</link>
    <description>&lt;P&gt;// Hi all,&lt;/P&gt;&lt;P&gt;// I am having an exception error while running the line indicated by purple color,&lt;/P&gt;&lt;P&gt;//exception image is also provided at bottom&lt;/P&gt;&lt;P&gt;// can I get the solution why I am getting this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ObjectCollection bodyCollection;&lt;BR /&gt;bodyCollection = inventorApplication.TransientObjects.CreateObjectCollection();&lt;BR /&gt;&lt;BR /&gt;bodyCollection.Add("Extrusion2");&lt;BR /&gt;bodyCollection.Add("Extrusion3");&lt;BR /&gt;object oangle = (360 *Math.PI)/180;&lt;BR /&gt;&lt;BR /&gt;CircularPatternFeatureDefinition pattern1;&lt;BR /&gt;pattern1 = oPartCompDef.Features.CircularPatternFeatures.&lt;BR /&gt;CreateDefinition(bodyCollection,oPartCompDef.WorkAxes[3],true,&lt;BR /&gt;noOfHolesRadially,oangle);&lt;BR /&gt;&lt;FONT color="#800080"&gt;CircularPatternFeature pa = oPartCompDef.Features.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#800080"&gt;CircularPatternFeatures.AddByDefinition(pattern1);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2019mmp003_1-1604930167848.png" style="width: 356px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/842081i17D1D6E5C1072540/image-dimensions/356x146?v=v2" width="356" height="146" role="button" title="2019mmp003_1-1604930167848.png" alt="2019mmp003_1-1604930167848.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 09 Nov 2020 14:01:47 GMT</pubDate>
    <dc:creator>2019mmp003</dc:creator>
    <dc:date>2020-11-09T14:01:47Z</dc:date>
    <item>
      <title>Exception while using circular pattern feature</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/exception-while-using-circular-pattern-feature/m-p/9855931#M117874</link>
      <description>&lt;P&gt;// Hi all,&lt;/P&gt;&lt;P&gt;// I am having an exception error while running the line indicated by purple color,&lt;/P&gt;&lt;P&gt;//exception image is also provided at bottom&lt;/P&gt;&lt;P&gt;// can I get the solution why I am getting this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ObjectCollection bodyCollection;&lt;BR /&gt;bodyCollection = inventorApplication.TransientObjects.CreateObjectCollection();&lt;BR /&gt;&lt;BR /&gt;bodyCollection.Add("Extrusion2");&lt;BR /&gt;bodyCollection.Add("Extrusion3");&lt;BR /&gt;object oangle = (360 *Math.PI)/180;&lt;BR /&gt;&lt;BR /&gt;CircularPatternFeatureDefinition pattern1;&lt;BR /&gt;pattern1 = oPartCompDef.Features.CircularPatternFeatures.&lt;BR /&gt;CreateDefinition(bodyCollection,oPartCompDef.WorkAxes[3],true,&lt;BR /&gt;noOfHolesRadially,oangle);&lt;BR /&gt;&lt;FONT color="#800080"&gt;CircularPatternFeature pa = oPartCompDef.Features.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#800080"&gt;CircularPatternFeatures.AddByDefinition(pattern1);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2019mmp003_1-1604930167848.png" style="width: 356px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/842081i17D1D6E5C1072540/image-dimensions/356x146?v=v2" width="356" height="146" role="button" title="2019mmp003_1-1604930167848.png" alt="2019mmp003_1-1604930167848.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Nov 2020 14:01:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/exception-while-using-circular-pattern-feature/m-p/9855931#M117874</guid>
      <dc:creator>2019mmp003</dc:creator>
      <dc:date>2020-11-09T14:01:47Z</dc:date>
    </item>
    <item>
      <title>Re: Exception while using circular pattern feature</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/exception-while-using-circular-pattern-feature/m-p/9855973#M117875</link>
      <description>&lt;P&gt;I noticed 'noOfHolesRadially' is not declared or set.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Nov 2020 14:14:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/exception-while-using-circular-pattern-feature/m-p/9855973#M117875</guid>
      <dc:creator>_dscholtes_</dc:creator>
      <dc:date>2020-11-09T14:14:28Z</dc:date>
    </item>
    <item>
      <title>Re: Exception while using circular pattern feature</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/exception-while-using-circular-pattern-feature/m-p/9856086#M117881</link>
      <description>&lt;P&gt;&lt;BR /&gt;private void button1_Click(object sender, EventArgs e)&lt;BR /&gt;{&lt;BR /&gt;Inventor.Application inventorApplication;&lt;BR /&gt;inventorApplication = (Inventor.Application)&lt;BR /&gt;Marshal.GetActiveObject("Inventor.Application");&lt;BR /&gt;PartDocument partDoc;&lt;BR /&gt;partDoc = (PartDocument)inventorApplication.Documents.Add&lt;BR /&gt;(DocumentTypeEnum.kPartDocumentObject,&lt;BR /&gt;inventorApplication.FileManager.GetTemplateFile&lt;BR /&gt;(DocumentTypeEnum.kPartDocumentObject));&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;PartComponentDefinition oPartCompDef;&lt;BR /&gt;oPartCompDef = partDoc.ComponentDefinition;&lt;BR /&gt;&lt;BR /&gt;PlanarSketch oSketch;&lt;BR /&gt;oSketch = oPartCompDef.Sketches.Add(oPartCompDef.WorkPlanes[3]);&lt;/P&gt;&lt;P&gt;TransientGeometry oTransGeom;&lt;BR /&gt;oTransGeom = inventorApplication.TransientGeometry;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;SketchCircle outerCircle,innerCircle;&lt;/P&gt;&lt;P&gt;outerCircle = oSketch.SketchCircles.AddByCenterRadius(oTransGeom.CreatePoint2d(0, 0),&lt;BR /&gt;Convert.ToDouble(outerdiameter.Text)/2);&lt;BR /&gt;innerCircle = oSketch.SketchCircles.AddByCenterRadius(oTransGeom.CreatePoint2d(0, 0),&lt;BR /&gt;(Convert.ToDouble(outerdiameter.Text) / 2)-&lt;BR /&gt;Convert.ToDouble(Thickness.Text));&lt;BR /&gt;Profile oProfile;&lt;BR /&gt;oProfile = oSketch.Profiles.AddForSolid();&lt;/P&gt;&lt;P&gt;ExtrudeDefinition oExtrudeDef;&lt;BR /&gt;oExtrudeDef = oPartCompDef.Features.ExtrudeFeatures.&lt;BR /&gt;CreateExtrudeDefinition(oProfile,&lt;BR /&gt;PartFeatureOperationEnum.kJoinOperation);&lt;BR /&gt;oExtrudeDef.SetDistanceExtent(Convert.ToDouble(cageheight.Text)&lt;BR /&gt;, PartFeatureExtentDirectionEnum.kPositiveExtentDirection);&lt;BR /&gt;ExtrudeFeature oExtrude;&lt;BR /&gt;oExtrude = oPartCompDef.Features.ExtrudeFeatures.Add(oExtrudeDef);&lt;BR /&gt;double outerDia = Convert.ToDouble(outerdiameter.Text);&lt;BR /&gt;double outerHoleDia = Convert.ToDouble(outerholediameter.Text);&lt;BR /&gt;double innerHoleDia = Convert.ToDouble(innerholediameter.Text);&lt;BR /&gt;double innerDia = Convert.ToDouble(outerdiameter.Text)-2*&lt;BR /&gt;(Convert.ToDouble(Thickness.Text));&lt;BR /&gt;double biggerDia = findBiggerHole(outerHoleDia, innerHoleDia);&lt;BR /&gt;double crossSectionAreaOfCage = (22 / 28) * innerDia * innerDia;&lt;BR /&gt;double height = Convert.ToDouble(cageheight.Text);&lt;BR /&gt;int noOfHolesAlongCageHeight = (int)((height - biggerDia) / (biggerDia * 2) + 0.5);&lt;/P&gt;&lt;P&gt;int totalNoOfHoles = (int)((innerDia * innerDia) / (biggerDia) * biggerDia);&lt;BR /&gt;int noOfHolesRadially = totalNoOfHoles / noOfHolesAlongCageHeight;&lt;BR /&gt;double angle = 360 / noOfHolesRadially;&lt;/P&gt;&lt;P&gt;WorkPlane outerHolePlane;&lt;BR /&gt;outerHolePlane = oPartCompDef.WorkPlanes.AddByPlaneAndOffset(oPartCompDef.&lt;BR /&gt;WorkPlanes[1], Convert.ToDouble(outerdiameter.Text)/2);&lt;BR /&gt;WorkPlane innerHolePlane;&lt;BR /&gt;innerHolePlane = oPartCompDef.WorkPlanes.AddByPlaneAndOffset(oPartCompDef.&lt;BR /&gt;WorkPlanes[1], innerDia/2);&lt;BR /&gt;&lt;BR /&gt;oSketch = oPartCompDef.Sketches.Add(outerHolePlane);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;List&amp;lt;SketchCircle&amp;gt; holes = new List&amp;lt;SketchCircle&amp;gt;(new SketchCircle[noOfHolesAlongCageHeight]);&lt;BR /&gt;double first = biggerDia;&lt;BR /&gt;for(int i=0;i&amp;lt;noOfHolesAlongCageHeight;i++)&lt;BR /&gt;{&lt;BR /&gt;holes[i] = oSketch.SketchCircles.AddByCenterRadius(oTransGeom.CreatePoint2d(0,first),&lt;BR /&gt;outerHoleDia / 2);&lt;BR /&gt;first = first + 2*biggerDia;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;Profile newProfile;&lt;BR /&gt;newProfile = oSketch.Profiles.AddForSolid();&lt;/P&gt;&lt;P&gt;ExtrudeDefinition newExtrudeDef;&lt;BR /&gt;newExtrudeDef = oPartCompDef.Features.ExtrudeFeatures.&lt;BR /&gt;CreateExtrudeDefinition(newProfile,&lt;BR /&gt;PartFeatureOperationEnum.kCutOperation);&lt;BR /&gt;newExtrudeDef.SetDistanceExtent(Convert.ToDouble(depth.Text),&lt;BR /&gt;PartFeatureExtentDirectionEnum.kNegativeExtentDirection);&lt;/P&gt;&lt;P&gt;ExtrudeFeature newExtrude;&lt;BR /&gt;newExtrude = oPartCompDef.Features.ExtrudeFeatures.Add(newExtrudeDef);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;oSketch = oPartCompDef.Sketches.Add(innerHolePlane);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;List&amp;lt;SketchCircle&amp;gt; innerHoles = new List&amp;lt;SketchCircle&amp;gt;(new SketchCircle[noOfHolesAlongCageHeight]);&lt;BR /&gt;double second = biggerDia;&lt;BR /&gt;for (int i = 0; i &amp;lt; noOfHolesAlongCageHeight; i++)&lt;BR /&gt;{&lt;BR /&gt;innerHoles[i] = oSketch.SketchCircles.AddByCenterRadius(oTransGeom.CreatePoint2d(0,second),&lt;BR /&gt;innerHoleDia / 2);&lt;BR /&gt;second = second + 2 * biggerDia;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;Profile newsProfile;&lt;BR /&gt;newsProfile = oSketch.Profiles.AddForSolid();&lt;/P&gt;&lt;P&gt;ExtrudeDefinition newsExtrudeDef;&lt;BR /&gt;newsExtrudeDef = oPartCompDef.Features.ExtrudeFeatures.&lt;BR /&gt;CreateExtrudeDefinition(newsProfile,&lt;BR /&gt;PartFeatureOperationEnum.kCutOperation);&lt;/P&gt;&lt;P&gt;newsExtrudeDef.SetDistanceExtent(Convert.ToDouble(depth.Text),&lt;BR /&gt;PartFeatureExtentDirectionEnum.kSymmetricExtentDirection);&lt;/P&gt;&lt;P&gt;ExtrudeFeature newsExtrude;&lt;BR /&gt;newsExtrude = oPartCompDef.Features.ExtrudeFeatures.Add(newsExtrudeDef);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ObjectCollection bodyCollection;&lt;BR /&gt;bodyCollection = inventorApplication.TransientObjects.CreateObjectCollection();&lt;/P&gt;&lt;P&gt;//foreach (ExtrudeFeature item in oPartCompDef.Features.ExtrudeFeatures)&lt;BR /&gt;//{&lt;BR /&gt;// if (item.Name == "Extrusion1")&lt;BR /&gt;// continue;&lt;BR /&gt;// else&lt;BR /&gt;// bodyCollection.Add(item);&lt;BR /&gt;//}&lt;BR /&gt;bodyCollection.Add("Extrusion2");&lt;BR /&gt;bodyCollection.Add("Extrusion3");&lt;/P&gt;&lt;P&gt;object oangle = (360 *Math.PI)/180;&lt;BR /&gt;&lt;BR /&gt;CircularPatternFeatureDefinition pattern1;&lt;BR /&gt;pattern1 = oPartCompDef.Features.CircularPatternFeatures.CreateDefinition(bodyCollection,oPartCompDef.WorkAxes[3],true,&lt;BR /&gt;noOfHolesRadially,oangle,true);&lt;BR /&gt;CircularPatternFeature pa = oPartCompDef.Features.CircularPatternFeatures.AddByDefinition(pattern1);&lt;BR /&gt;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Nov 2020 14:56:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/exception-while-using-circular-pattern-feature/m-p/9856086#M117881</guid>
      <dc:creator>2019mmp003</dc:creator>
      <dc:date>2020-11-09T14:56:51Z</dc:date>
    </item>
  </channel>
</rss>

