<?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 Add Pattern Into Another Pattern In Assembly in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-to-add-pattern-into-another-pattern-in-assembly/m-p/9183213#M103671</link>
    <description>&lt;P&gt;try this:&lt;/P&gt;&lt;PRE&gt;Dim oDoc As Document = ThisApplication.ActiveDocument
Dim oAsmCompDef As AssemblyComponentDefinition = oDoc.ComponentDefinition
Dim oOccPattern1 As OccurrencePattern
Dim oOccPattern2 As OccurrencePattern
Dim oObjCol As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection

Dim FirstPattern As String = "Pattern One"
Dim SecondPattern As String = "Pattern Two"
'add second pattern inside first pattern

Dim occurrencePattern1 As OccurrencePattern = Nothing
Dim occurrencePattern2 As OccurrencePattern = Nothing

For Each oOccPattern In oAsmCompDef.OccurrencePatterns
    If oOccPattern.Name = FirstPattern Then 'looks for the first pattern inside the assembly
        occurrencePattern1 = oOccPattern
    End If
    If oOccPattern.Name = SecondPattern Then 'looks for the second pattern inside the assembly
        occurrencePattern2 = oOccPattern
    End If
Next

If (occurrencePattern1 Is Nothing Or occurrencePattern2 Is Nothing) Then
    MsgBox("Paterns not found")
End If

Dim oOccurrences As ObjectCollection = occurrencePattern1.ParentComponents
oOccurrences.Add(occurrencePattern2)

occurrencePattern1.ParentComponents = oOccurrences&lt;/PRE&gt;</description>
    <pubDate>Wed, 04 Dec 2019 21:26:27 GMT</pubDate>
    <dc:creator>JelteDeJong</dc:creator>
    <dc:date>2019-12-04T21:26:27Z</dc:date>
    <item>
      <title>iLogic To Add Pattern Into Another Pattern In Assembly</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-to-add-pattern-into-another-pattern-in-assembly/m-p/9180789#M103619</link>
      <description>&lt;P&gt;Hey forum,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have two patterns and I am trying to add one pattern inside the other but I am unsure how to do this with iLogic. I think I have to make an object collection of the pattern that needs to be patterned again ("Pattern Two").&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's how I've approached it so far:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;	&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oDoc&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;Document&lt;/SPAN&gt; = &lt;SPAN&gt;ThisApplication&lt;/SPAN&gt;.&lt;SPAN&gt;ActiveDocument&lt;/SPAN&gt;
	&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oAsmCompDef&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;AssemblyComponentDefinition&lt;/SPAN&gt; = &lt;SPAN&gt;oDoc&lt;/SPAN&gt;.&lt;SPAN&gt;ComponentDefinition&lt;/SPAN&gt;
	&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oOccPattern1&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;OccurrencePattern &lt;/SPAN&gt;
	&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oOccPattern2&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;OccurrencePattern&lt;/SPAN&gt;
	&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oObjCol&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;Dim&lt;/SPAN&gt; &lt;SPAN&gt;FirstPattern&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;String&lt;/SPAN&gt; = &lt;SPAN&gt;"Pattern One"&lt;/SPAN&gt;
	&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;SecondPattern&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;String&lt;/SPAN&gt; = &lt;SPAN&gt;"Pattern Two"&lt;/SPAN&gt;
	&lt;SPAN&gt;'add second pattern inside first pattern&lt;/SPAN&gt;
	
	&lt;SPAN&gt;For&lt;/SPAN&gt; &lt;SPAN&gt;Each&lt;/SPAN&gt; &lt;SPAN&gt;oOccPattern1&lt;/SPAN&gt; &lt;SPAN&gt;In&lt;/SPAN&gt; &lt;SPAN&gt;oAsmCompDef&lt;/SPAN&gt;.&lt;SPAN&gt;OccurrencePatterns&lt;/SPAN&gt; 
		&lt;SPAN&gt;If&lt;/SPAN&gt; &lt;SPAN&gt;oOccPattern1&lt;/SPAN&gt;.&lt;SPAN&gt;Name&lt;/SPAN&gt; = &lt;SPAN&gt;FirstPattern&lt;/SPAN&gt; &lt;SPAN&gt;Then&lt;/SPAN&gt; 'looks for the first pattern inside the assembly
			&lt;SPAN&gt;For&lt;/SPAN&gt; &lt;SPAN&gt;Each&lt;/SPAN&gt; &lt;SPAN&gt;oOccPattern2&lt;/SPAN&gt; &lt;SPAN&gt;In&lt;/SPAN&gt; &lt;SPAN&gt;oAsmCompDef&lt;/SPAN&gt;.&lt;SPAN&gt;OccurrencePatterns&lt;/SPAN&gt; 
				&lt;SPAN&gt;If&lt;/SPAN&gt; &lt;SPAN&gt;oOccPattern2&lt;/SPAN&gt;.&lt;SPAN&gt;Name&lt;/SPAN&gt; = &lt;SPAN&gt;SecondPattern&lt;/SPAN&gt; &lt;SPAN&gt;Then&lt;/SPAN&gt; 'looks for the second pattern inside the assembly
					&lt;SPAN&gt;oObjCol&lt;/SPAN&gt;.&lt;SPAN&gt;Add&lt;/SPAN&gt;(&lt;SPAN&gt;oOccPattern2&lt;/SPAN&gt;) 'adds the second pattern into a collection
					&lt;SPAN&gt;oOccPattern1&lt;/SPAN&gt;.&lt;SPAN&gt;ParentComponents&lt;/SPAN&gt;.&lt;SPAN&gt;Add&lt;/SPAN&gt;(&lt;SPAN&gt;oObjCol&lt;/SPAN&gt;)
				&lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;If&lt;/SPAN&gt; 
			&lt;SPAN&gt;Next&lt;/SPAN&gt; &lt;BR /&gt;E
		&lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;If&lt;/SPAN&gt;
	&lt;SPAN&gt;Next&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help is greatly appreciated!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Felix&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Dec 2019 22:06:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-to-add-pattern-into-another-pattern-in-assembly/m-p/9180789#M103619</guid>
      <dc:creator>felix.cortes5K3Y2</dc:creator>
      <dc:date>2019-12-03T22:06:31Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic To Add Pattern Into Another Pattern In Assembly</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-to-add-pattern-into-another-pattern-in-assembly/m-p/9183213#M103671</link>
      <description>&lt;P&gt;try this:&lt;/P&gt;&lt;PRE&gt;Dim oDoc As Document = ThisApplication.ActiveDocument
Dim oAsmCompDef As AssemblyComponentDefinition = oDoc.ComponentDefinition
Dim oOccPattern1 As OccurrencePattern
Dim oOccPattern2 As OccurrencePattern
Dim oObjCol As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection

Dim FirstPattern As String = "Pattern One"
Dim SecondPattern As String = "Pattern Two"
'add second pattern inside first pattern

Dim occurrencePattern1 As OccurrencePattern = Nothing
Dim occurrencePattern2 As OccurrencePattern = Nothing

For Each oOccPattern In oAsmCompDef.OccurrencePatterns
    If oOccPattern.Name = FirstPattern Then 'looks for the first pattern inside the assembly
        occurrencePattern1 = oOccPattern
    End If
    If oOccPattern.Name = SecondPattern Then 'looks for the second pattern inside the assembly
        occurrencePattern2 = oOccPattern
    End If
Next

If (occurrencePattern1 Is Nothing Or occurrencePattern2 Is Nothing) Then
    MsgBox("Paterns not found")
End If

Dim oOccurrences As ObjectCollection = occurrencePattern1.ParentComponents
oOccurrences.Add(occurrencePattern2)

occurrencePattern1.ParentComponents = oOccurrences&lt;/PRE&gt;</description>
      <pubDate>Wed, 04 Dec 2019 21:26:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-to-add-pattern-into-another-pattern-in-assembly/m-p/9183213#M103671</guid>
      <dc:creator>JelteDeJong</dc:creator>
      <dc:date>2019-12-04T21:26:27Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic To Add Pattern Into Another Pattern In Assembly</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-to-add-pattern-into-another-pattern-in-assembly/m-p/9189597#M103788</link>
      <description>&lt;P&gt;Thank you Jelte&lt;/P&gt;</description>
      <pubDate>Sun, 08 Dec 2019 15:24:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-to-add-pattern-into-another-pattern-in-assembly/m-p/9189597#M103788</guid>
      <dc:creator>felix.cortes5K3Y2</dc:creator>
      <dc:date>2019-12-08T15:24:00Z</dc:date>
    </item>
  </channel>
</rss>

