<?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 Re: iLogic to Create Rectangular Pattern Of Part Feature in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-to-create-rectangular-pattern-of-part-feature/m-p/8839195#M98179</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/7060191"&gt;@felix.cortes5K3Y2&lt;/a&gt;&amp;nbsp;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Attached is an example part file ( saved in Inventor 2017 ) for you to look at.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I just adapted the code/file found at this link for this example.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://forums.autodesk.com/t5/inventor-customization/rectangular-pattern-part-ilogic/m-p/7599859#M77707" target="_blank"&gt;https://forums.autodesk.com/t5/inventor-customization/rectangular-pattern-part-ilogic/m-p/7599859#M77707&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below is the code found in the file in cases it helps future searches.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope this helps.&lt;BR /&gt;Best of luck to you in all of your Inventor pursuits,&lt;BR /&gt;Curtis&lt;BR /&gt;&lt;A href="http://inventortrenches.blogspot.com" target="_blank"&gt;http://inventortrenches.blogspot.com&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;'try to delete previous pattern, just for testing
Try
ThisApplication.ActiveDocument.ComponentDefinition.Features("TestPattern").delete
Catch
End Try

Dim oPD As PartDocument
oPD = ThisApplication.ActiveDocument

Dim oPCD As PartComponentDefinition
oPCD = oPD.ComponentDefinition

Dim oSWP As WorkPlane
oSWP = oPCD.WorkPlanes.Item(4)

Dim oBjCol As ObjectCollection
oBjCol = ThisApplication.TransientObjects.CreateObjectCollection

Call oBjCol.Add(oSWP)

Dim oSL3D As SketchLine3D
oSL3D = oPCD.Sketches3D.Item(1).SketchLines3D.Item(1)

Dim qtypattern As Integer
qtypattern = InputBox("How many to Pattern?", "Quantity of Pattern")


Dim oPath As Object
oPath = oPCD.Features.CreatePath(oSL3D)

Dim oRecFeat As RectangularPatternFeature
DistPrompt1 = InputBox("Input Distance of Pattern in cm?", "Distance of Pattern")

oRecFeat = oPCD.Features.RectangularPatternFeatures.Add(oBjCol, oPath, True, qtypattern, DistPrompt1, PatternSpacingTypeEnum.kDefault)

'rename pattern
oRecFeat.Name = "TestPattern"
&lt;/PRE&gt;</description>
    <pubDate>Fri, 07 Jun 2019 15:58:14 GMT</pubDate>
    <dc:creator>Curtis_Waguespack</dc:creator>
    <dc:date>2019-06-07T15:58:14Z</dc:date>
    <item>
      <title>iLogic to Create Rectangular Pattern Of Part Feature</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-to-create-rectangular-pattern-of-part-feature/m-p/8839112#M98177</link>
      <description>&lt;P&gt;Hi Forum,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to write a code to create the a rectangular feature pattern and was wondering if someone could help me out. Here's what I have right now:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oPartDoc&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;PartDocument&lt;/SPAN&gt; = &lt;SPAN&gt;ThisDoc&lt;/SPAN&gt;.&lt;SPAN&gt;Document&lt;/SPAN&gt;
&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oCompDef&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;PartComponentDefinition&lt;/SPAN&gt; = &lt;SPAN&gt;oPartDoc&lt;/SPAN&gt;.&lt;SPAN&gt;ComponentDefinition&lt;/SPAN&gt;

&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oRectDef&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;RectangularPatternFeatureDefinition&lt;/SPAN&gt; = &lt;SPAN&gt;oCompDef&lt;/SPAN&gt;.&lt;SPAN&gt;Features&lt;/SPAN&gt;.&lt;SPAN&gt;RectangularPatternFeatures&lt;/SPAN&gt;.&lt;SPAN&gt;CreateDefinition&lt;/SPAN&gt;(&lt;SPAN&gt;"TOP"&lt;/SPAN&gt;, &lt;SPAN&gt;"X-Axis"&lt;/SPAN&gt;, _
														&lt;SPAN&gt;True&lt;/SPAN&gt;, 2, 10)
&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oPartFeature&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;PartFeature&lt;/SPAN&gt; = &lt;SPAN&gt;oCompDef&lt;/SPAN&gt;.&lt;SPAN&gt;Features&lt;/SPAN&gt;.&lt;SPAN&gt;RectangularPatternFeatures&lt;/SPAN&gt;.&lt;SPAN&gt;AddByDefinition&lt;/SPAN&gt;(&lt;SPAN&gt;oRectDef&lt;/SPAN&gt;)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Felix&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jun 2019 15:28:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-to-create-rectangular-pattern-of-part-feature/m-p/8839112#M98177</guid>
      <dc:creator>felix.cortes5K3Y2</dc:creator>
      <dc:date>2019-06-07T15:28:39Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic to Create Rectangular Pattern Of Part Feature</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-to-create-rectangular-pattern-of-part-feature/m-p/8839195#M98179</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/7060191"&gt;@felix.cortes5K3Y2&lt;/a&gt;&amp;nbsp;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Attached is an example part file ( saved in Inventor 2017 ) for you to look at.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I just adapted the code/file found at this link for this example.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://forums.autodesk.com/t5/inventor-customization/rectangular-pattern-part-ilogic/m-p/7599859#M77707" target="_blank"&gt;https://forums.autodesk.com/t5/inventor-customization/rectangular-pattern-part-ilogic/m-p/7599859#M77707&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below is the code found in the file in cases it helps future searches.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope this helps.&lt;BR /&gt;Best of luck to you in all of your Inventor pursuits,&lt;BR /&gt;Curtis&lt;BR /&gt;&lt;A href="http://inventortrenches.blogspot.com" target="_blank"&gt;http://inventortrenches.blogspot.com&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;'try to delete previous pattern, just for testing
Try
ThisApplication.ActiveDocument.ComponentDefinition.Features("TestPattern").delete
Catch
End Try

Dim oPD As PartDocument
oPD = ThisApplication.ActiveDocument

Dim oPCD As PartComponentDefinition
oPCD = oPD.ComponentDefinition

Dim oSWP As WorkPlane
oSWP = oPCD.WorkPlanes.Item(4)

Dim oBjCol As ObjectCollection
oBjCol = ThisApplication.TransientObjects.CreateObjectCollection

Call oBjCol.Add(oSWP)

Dim oSL3D As SketchLine3D
oSL3D = oPCD.Sketches3D.Item(1).SketchLines3D.Item(1)

Dim qtypattern As Integer
qtypattern = InputBox("How many to Pattern?", "Quantity of Pattern")


Dim oPath As Object
oPath = oPCD.Features.CreatePath(oSL3D)

Dim oRecFeat As RectangularPatternFeature
DistPrompt1 = InputBox("Input Distance of Pattern in cm?", "Distance of Pattern")

oRecFeat = oPCD.Features.RectangularPatternFeatures.Add(oBjCol, oPath, True, qtypattern, DistPrompt1, PatternSpacingTypeEnum.kDefault)

'rename pattern
oRecFeat.Name = "TestPattern"
&lt;/PRE&gt;</description>
      <pubDate>Fri, 07 Jun 2019 15:58:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-to-create-rectangular-pattern-of-part-feature/m-p/8839195#M98179</guid>
      <dc:creator>Curtis_Waguespack</dc:creator>
      <dc:date>2019-06-07T15:58:14Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic to Create Rectangular Pattern Of Part Feature</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-to-create-rectangular-pattern-of-part-feature/m-p/8839671#M98189</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Thanks for the link! It doesn't work for my application but I think the code provided below is pretty darn close to being able to create it. I tried classifying the sweep that exists on my part as a object collection but it doesn't seem to work on the last line of code.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oPartDoc&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;PartDocument&lt;/SPAN&gt; = &lt;SPAN&gt;ThisDoc&lt;/SPAN&gt;.&lt;SPAN&gt;Document&lt;/SPAN&gt;
&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oPartComp&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;PartComponentDefinition&lt;/SPAN&gt; = &lt;SPAN&gt;oPartDoc&lt;/SPAN&gt;.&lt;SPAN&gt;ComponentDefinition&lt;/SPAN&gt;
&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oSweep&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;SweepFeature&lt;/SPAN&gt; = &lt;SPAN&gt;oPartComp&lt;/SPAN&gt;.&lt;SPAN&gt;Features&lt;/SPAN&gt;.&lt;SPAN&gt;SweepFeatures&lt;/SPAN&gt;.&lt;SPAN&gt;Item&lt;/SPAN&gt;(2)
&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oBjCol&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;ObjectCollection&lt;/SPAN&gt; = &lt;SPAN&gt;ThisApplication&lt;/SPAN&gt;.&lt;SPAN&gt;TransientObjects&lt;/SPAN&gt;.&lt;SPAN&gt;CreateObjectCollection&lt;/SPAN&gt;
&lt;SPAN&gt;Call&lt;/SPAN&gt; &lt;SPAN&gt;oBjCol&lt;/SPAN&gt;.&lt;SPAN&gt;Add&lt;/SPAN&gt;(&lt;SPAN&gt;oSweep&lt;/SPAN&gt;)
&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oAxis&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;WorkAxis&lt;/SPAN&gt; = &lt;SPAN&gt;oPartComp&lt;/SPAN&gt;.&lt;SPAN&gt;WorkAxes&lt;/SPAN&gt;.&lt;SPAN&gt;Item&lt;/SPAN&gt;(1)
&lt;SPAN&gt;oRectFeat&lt;/SPAN&gt; = &lt;SPAN&gt;oPartComp&lt;/SPAN&gt;.&lt;SPAN&gt;Features&lt;/SPAN&gt;.&lt;SPAN&gt;RectangularPatternFeatures&lt;/SPAN&gt;.&lt;SPAN&gt;Add&lt;/SPAN&gt;(&lt;SPAN&gt;oBjCol&lt;/SPAN&gt;, &lt;SPAN&gt;oAxis&lt;/SPAN&gt;, &lt;SPAN&gt;True&lt;/SPAN&gt;, 3, 10, &lt;SPAN&gt;PatternSpacingTypeEnum&lt;/SPAN&gt;.&lt;SPAN&gt;kDefault&lt;/SPAN&gt;)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Felix Cortes&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jun 2019 20:01:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-to-create-rectangular-pattern-of-part-feature/m-p/8839671#M98189</guid>
      <dc:creator>felix.cortes5K3Y2</dc:creator>
      <dc:date>2019-06-07T20:01:24Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic to Create Rectangular Pattern Of Part Feature</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-to-create-rectangular-pattern-of-part-feature/m-p/8840446#M98193</link>
      <description>&lt;P&gt;Hi, try this code. I think you can put the name of the operation instead of the item number, try it and then tell us. I hope the code is useful for you. regards&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oPD&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;PartDocument&lt;/SPAN&gt; = &lt;SPAN&gt;ThisDoc&lt;/SPAN&gt;.&lt;SPAN&gt;Document&lt;/SPAN&gt;
&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oPCD&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;PartComponentDefinition&lt;/SPAN&gt; = &lt;SPAN&gt;oPD&lt;/SPAN&gt;.&lt;SPAN&gt;ComponentDefinition&lt;/SPAN&gt;
&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;Xaxis&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;Object&lt;/SPAN&gt; = &lt;SPAN&gt;oPCD&lt;/SPAN&gt;.&lt;SPAN&gt;WorkAxes&lt;/SPAN&gt;.&lt;SPAN&gt;Item&lt;/SPAN&gt;(1)' Select X Axis

&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oTop&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;PartFeature&lt;/SPAN&gt; = &lt;SPAN&gt;oPCD&lt;/SPAN&gt;.&lt;SPAN&gt;Features&lt;/SPAN&gt;.&lt;SPAN&gt;Item&lt;/SPAN&gt;(1) ' Select Feature form item number 

&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oBjCol&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;ObjectCollection&lt;/SPAN&gt;
&lt;SPAN&gt;oBjCol&lt;/SPAN&gt; = &lt;SPAN&gt;ThisApplication&lt;/SPAN&gt;.&lt;SPAN&gt;TransientObjects&lt;/SPAN&gt;.&lt;SPAN&gt;CreateObjectCollection&lt;/SPAN&gt;
	&lt;SPAN&gt;Call&lt;/SPAN&gt; &lt;SPAN&gt;oBjCol&lt;/SPAN&gt;.&lt;SPAN&gt;Add&lt;/SPAN&gt;(&lt;SPAN&gt;oTop&lt;/SPAN&gt;)

&lt;SPAN&gt;oRecFeat&lt;/SPAN&gt; = &lt;SPAN&gt;oPCD&lt;/SPAN&gt;.&lt;SPAN&gt;Features&lt;/SPAN&gt;.&lt;SPAN&gt;RectangularPatternFeatures&lt;/SPAN&gt;.&lt;SPAN&gt;Add&lt;/SPAN&gt;(&lt;SPAN&gt;oBjCol&lt;/SPAN&gt;,&lt;SPAN&gt;Xaxis&lt;/SPAN&gt;,&lt;SPAN&gt;True&lt;/SPAN&gt;, 5, 1, &lt;SPAN&gt;kDefault&lt;/SPAN&gt;, , , , , , , , &lt;SPAN&gt;kAdjustToModelCompute&lt;/SPAN&gt;, &lt;SPAN&gt;kAdjustToDirection1&lt;/SPAN&gt;)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 08 Jun 2019 15:44:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-to-create-rectangular-pattern-of-part-feature/m-p/8840446#M98193</guid>
      <dc:creator>Sergio.D.Suárez</dc:creator>
      <dc:date>2019-06-08T15:44:48Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic to Create Rectangular Pattern Of Part Feature</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-to-create-rectangular-pattern-of-part-feature/m-p/8840696#M98196</link>
      <description>&lt;P&gt;Thanks a ton Sergio! Works great&lt;/P&gt;</description>
      <pubDate>Sat, 08 Jun 2019 23:02:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-to-create-rectangular-pattern-of-part-feature/m-p/8840696#M98196</guid>
      <dc:creator>felix.cortes5K3Y2</dc:creator>
      <dc:date>2019-06-08T23:02:36Z</dc:date>
    </item>
  </channel>
</rss>

