<?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: Assembly pattern and color ilogic in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/assembly-pattern-and-color-ilogic/m-p/9841122#M117580</link>
    <description>&lt;P&gt;This is how you can get an OccurrencePattern Object From a selected ComponentOccurrence:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Dim OccPat As OccurrencePattern = Occ.PatternElement.Parent
'Where Occ is a ComponentOccurrence and Occ.IsPatternElement = True&lt;/LI-CODE&gt;&lt;P&gt;&lt;A href="http://help.autodesk.com/view/INVNTOR/2019/ENU/?guid=GUID-15FB4435-5BE2-4B2D-983F-435BB69D9CCC" target="_blank" rel="noopener"&gt;OccurrencePattern Object&lt;/A&gt;&amp;nbsp; has a Property "OccurrencePatternElements", which you can iterate through as &lt;A href="http://help.autodesk.com/view/INVNTOR/2019/ENU/?guid=GUID-C73D4AEB-7535-4775-903F-F41BEBBBF272" target="_blank" rel="noopener"&gt;OccurrencePatternElement Objects&lt;/A&gt; to find the Occurrences that make up each Element.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 02 Nov 2020 21:37:47 GMT</pubDate>
    <dc:creator>J-Camper</dc:creator>
    <dc:date>2020-11-02T21:37:47Z</dc:date>
    <item>
      <title>Assembly pattern and color ilogic</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/assembly-pattern-and-color-ilogic/m-p/9840988#M117574</link>
      <description>&lt;P&gt;I am blanking here, If I have a component pattern in an assembly, how do I select the pattern and change the color with Ilogic.. I can only seem to change per instance name. I cant seem to find how to select the entire pattern and set all occurrences appearances at once. Also I am blanking on how to dive down to the part and set the color at the part level if I dont have a color rule to fire at the part level.&lt;/P&gt;</description>
      <pubDate>Mon, 02 Nov 2020 20:29:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/assembly-pattern-and-color-ilogic/m-p/9840988#M117574</guid>
      <dc:creator>blandb</dc:creator>
      <dc:date>2020-11-02T20:29:45Z</dc:date>
    </item>
    <item>
      <title>Re: Assembly pattern and color ilogic</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/assembly-pattern-and-color-ilogic/m-p/9841122#M117580</link>
      <description>&lt;P&gt;This is how you can get an OccurrencePattern Object From a selected ComponentOccurrence:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Dim OccPat As OccurrencePattern = Occ.PatternElement.Parent
'Where Occ is a ComponentOccurrence and Occ.IsPatternElement = True&lt;/LI-CODE&gt;&lt;P&gt;&lt;A href="http://help.autodesk.com/view/INVNTOR/2019/ENU/?guid=GUID-15FB4435-5BE2-4B2D-983F-435BB69D9CCC" target="_blank" rel="noopener"&gt;OccurrencePattern Object&lt;/A&gt;&amp;nbsp; has a Property "OccurrencePatternElements", which you can iterate through as &lt;A href="http://help.autodesk.com/view/INVNTOR/2019/ENU/?guid=GUID-C73D4AEB-7535-4775-903F-F41BEBBBF272" target="_blank" rel="noopener"&gt;OccurrencePatternElement Objects&lt;/A&gt; to find the Occurrences that make up each Element.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Nov 2020 21:37:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/assembly-pattern-and-color-ilogic/m-p/9841122#M117580</guid>
      <dc:creator>J-Camper</dc:creator>
      <dc:date>2020-11-02T21:37:47Z</dc:date>
    </item>
    <item>
      <title>Re: Assembly pattern and color ilogic</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/assembly-pattern-and-color-ilogic/m-p/9842749#M117617</link>
      <description>&lt;P&gt;Can you share an example of how to properly use that in a select case statement?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Select Case PAINT&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Case "BLACK"&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Component.Color("PICKET") = "Black"&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Case "BLUE"&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Component.Color("PICKET") = "Blue"&lt;/P&gt;&lt;P&gt;End Select&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your assistance!&lt;/P&gt;</description>
      <pubDate>Tue, 03 Nov 2020 14:32:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/assembly-pattern-and-color-ilogic/m-p/9842749#M117617</guid>
      <dc:creator>blandb</dc:creator>
      <dc:date>2020-11-03T14:32:46Z</dc:date>
    </item>
    <item>
      <title>Re: Assembly pattern and color ilogic</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/assembly-pattern-and-color-ilogic/m-p/9842853#M117618</link>
      <description>&lt;P&gt;You should be able to set up your color selection in the Subroutine I have set up [with top level assembly and a single Occurrence].&amp;nbsp; I don't change the color of Occurrences with iLogic, so I'm not sure of the best way to set that portion up.&amp;nbsp; Here is a bit of code I threw together:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Sub Main
'External Rule Lockout
If ThisApplication.ActiveDocumentType &amp;lt;&amp;gt; kAssemblyDocumentObject Then MessageBox.Show("This rule is designed to only work in assembly documents.", "Wrong Document Type") : Exit Sub
'User Selection Setup, can be done other ways
Dim ocList As New List(Of String)
For Each oc As ComponentOccurrence In ThisApplication.ActiveDocument.ComponentDefinition.Occurrences
	If oc.DefinitionDocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then ocList.Add(oc.Name)
Next
Dim Selection As String = InputListBox("", ocList, ocList.Item(0), Title := "Item to Remove", ListName := "Sub Assemblies")
If IsNothing(Selection) Then Exit Sub 'No selection made
'After Occurrence is selected. "Selection" string can be manually set or set by a list and some logic to choose.
Dim selOcc As ComponentOccurrence = ThisApplication.ActiveDocument.ComponentDefinition.Occurrences.ItemByName(Selection)
'Verify selected occurrence is part of a pattern
If selOcc.IsPatternElement
	Dim Col As ObjectCollection = FindParticipants(selOcc)
	For Each oOcc As ComponentOccurrence In Col
		Call ColorSetting(ThisApplication.ActiveDocument, oOcc)
	Next
Else
	If MessageBox.Show("The Selected Occurrence: " &amp;amp; selOcc.Name &amp;amp; "  is not part of a Pattern.  Would you like to Set Color for this Occurrence Individually?", "Single Occurrence", MessageBoxButtons.YesNo) = vbYes Then Call ColorSetting(ThisApplication.ActiveDocument, selOcc)
End If

End Sub

Function FindParticipants(Oc As ComponentOccurrence) As ObjectCollection
	Dim Result As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
	Dim level1 As OccurrencePattern = Oc.PatternElement.Parent
LoopHere :
	For Each Element In level1.OccurrencePatternElements
		For Each Occ In Element.Occurrences
			Result.Add(Occ)
		Next
	Next
	'Dig through further patterns if initial pattern is an element
	If level1.IsPatternElement
		level1 = level1.PatternElement.Parent
		GoTo LoopHere
	End If
	Return Result
End Function

Sub ColorSetting(parent As AssemblyDocument, Oc As ComponentOccurrence)
	
	MessageBox.Show(Oc.Name, "Testing")
	
	'Setup your case selection here
	
End Sub&lt;/LI-CODE&gt;&lt;P&gt;The selection process can be modified, I just threw a list selection in there for now.&lt;/P&gt;</description>
      <pubDate>Tue, 03 Nov 2020 15:10:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/assembly-pattern-and-color-ilogic/m-p/9842853#M117618</guid>
      <dc:creator>J-Camper</dc:creator>
      <dc:date>2020-11-03T15:10:26Z</dc:date>
    </item>
    <item>
      <title>Re: Assembly pattern and color ilogic</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/assembly-pattern-and-color-ilogic/m-p/9842875#M117619</link>
      <description>&lt;P&gt;Way more involved than I thought it would be. I usually just change the material of components and they already have appearances associated. I appreciate your help, we have went a different path. Sorry for you wasting your time on this.&lt;/P&gt;</description>
      <pubDate>Tue, 03 Nov 2020 15:17:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/assembly-pattern-and-color-ilogic/m-p/9842875#M117619</guid>
      <dc:creator>blandb</dc:creator>
      <dc:date>2020-11-03T15:17:40Z</dc:date>
    </item>
  </channel>
</rss>

