<?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: How to get the Inventor OccurrencePatternProxys from a sub assembly? in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/how-to-get-the-inventor-occurrencepatternproxys-from-a-sub/m-p/12013914#M153532</link>
    <description>&lt;P&gt;I copied and pasted your code, but i am getting the same result.I would like to mention that I am making an AddIn so I slightly had to correct the code so a button is triggering the function.&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;Private Sub Button_test_Click(sender As Object, e As EventArgs) Handles Button_test.Click
        Try
            Dim oDoc As AssemblyDocument = g_inventorApplication.ActiveDocument
            Dim oColl As ObjectCollection = g_inventorApplication.TransientObjects.CreateObjectCollection
            Dim oDef As AssemblyComponentDefinition = oDoc.ComponentDefinition
            Call GetAllPatterns(oDef.OccurrencePatterns, oColl)
            Call GetAllOccs(oDef.Occurrences, oColl)

            If oColl Is Nothing Then Exit Sub

            For Each obj In oColl
                PrintToLog(obj.Name)
            Next

            oDoc.SelectSet.SelectMultiple(oColl)
            'oDoc.Rebuild()
            'oDoc.Update()

        Catch ex As Exception
            MsgBox(ex.ToString())
        End Try
    End Sub

    Private Sub GetAllOccs(oOccs As ComponentOccurrences, ByRef oColl As ObjectCollection)
        For Each oOcc As ComponentOccurrence In oOccs
            If oOcc.Suppressed Then Continue For
            If oOcc.DefinitionDocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
                Dim oOccDef As AssemblyComponentDefinition = oOcc.Definition
                Dim oOccDoc As AssemblyDocument = oOccDef.Document
                Call GetAllPatterns(oOccDef.OccurrencePatterns, oColl)
                If oOcc.SubOccurrences Is Nothing Then Continue For
                If oOcc.SubOccurrences.Count &amp;lt;&amp;gt; 0 Then
                    Call GetAllOccs(oOcc.SubOccurrences, oColl)
                End If
            End If

            oColl.Add(oOcc)
        Next
    End Sub

    Private Function GetAllPatterns(oOccsPatt As OccurrencePatterns, ByRef oColl As ObjectCollection)
        For Each oOccPatt As OccurrencePattern In oOccsPatt

            ' Work with visible
            oOccPatt.Visible = False

            ' Work with suppress
            oOccPatt.Suppress(True)

            'Select patterns
            oColl.Add(oOccPatt)

        Next
    End Function&lt;/LI-CODE&gt;&lt;P&gt;If I leave the line where it should suppress the patterns it gives an error: Public member 'Suppress' on type 'RectangularOccurrencePattern' not found.&lt;/P&gt;&lt;P&gt;If I comment out that line it gives an error at the 'SelectSet.SelectMultiple' where it gives an error: The parameter is incorrect.&lt;/P&gt;&lt;P&gt;The visibility line is ignored every time.&lt;/P&gt;&lt;P&gt;I need to point out that this problem persists only on lower level patterns. If I only look for top level patterns it works fine as expected.&lt;/P&gt;</description>
    <pubDate>Tue, 06 Jun 2023 08:49:17 GMT</pubDate>
    <dc:creator>jaka73LU2</dc:creator>
    <dc:date>2023-06-06T08:49:17Z</dc:date>
    <item>
      <title>How to get the Inventor OccurrencePatternProxys from a sub assembly?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/how-to-get-the-inventor-occurrencepatternproxys-from-a-sub/m-p/12011475#M153481</link>
      <description>&lt;P&gt;I am treversing an assembly and are trying to delete, hide, and suppress components. I have no problem with the components on the top level assembly (main assembly), but I have a problem with the lower level components, specificly patterns.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I kind of figured out that if I wanted to delete, hide or suppress lower level components I need a proxy object. That is easy for regular components that are of the type componentOccurrence. I get those throu the property SubOccurrences on the specified assembly.&amp;nbsp;&lt;/P&gt;&lt;P&gt;But I can't figure out how to get the proxys of the type occurrencePattern. There seams to be no property for those, or any other way for searching for them.&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="jaka73LU2_0-1685960191300.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1223626iDCFC11F21962A89D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jaka73LU2_0-1685960191300.png" alt="jaka73LU2_0-1685960191300.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Jun 2023 10:19:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/how-to-get-the-inventor-occurrencepatternproxys-from-a-sub/m-p/12011475#M153481</guid>
      <dc:creator>jaka73LU2</dc:creator>
      <dc:date>2023-06-05T10:19:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the Inventor OccurrencePatternProxys from a sub assembly?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/how-to-get-the-inventor-occurrencepatternproxys-from-a-sub/m-p/12011831#M153489</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/12498327"&gt;@jaka73LU2&lt;/a&gt;&amp;nbsp;.&amp;nbsp;Wrote for you an example of obtaining all patterns (in the main assembly and subassemblies).&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;Private Sub Main()
	Dim oDoc As AssemblyDocument = ThisApplication.ActiveDocument
	Dim oDef As AssemblyComponentDefinition = oDoc.ComponentDefinition
	Call GetAllPatterns(oDef.OccurrencePatterns, oDoc.DisplayName)
	Call GetAllOccs(oDef.Occurrences)	
End Sub

Private Sub GetAllOccs(oOccs As ComponentOccurrences)
	For Each oOcc As ComponentOccurrence In oOccs
		If oOcc.DefinitionDocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
			Dim oOccDef As AssemblyComponentDefinition = oOcc.Definition
			Call GetAllPatterns(oOccDef.OccurrencePatterns, oOcc.Name)
			If oOcc.SubOccurrences Is Nothing Then Continue For
			If oOcc.SubOccurrences.Count &amp;lt;&amp;gt; 0 Then
				Call GetAllOccs(oOcc.SubOccurrences)
			End If
		End If
	Next
End Sub

Private Function GetAllPatterns(oOccsPatt As OccurrencePatterns, sNameParent As String)
	For Each oOccPatt As OccurrencePattern In oOccsPatt
		MessageBox.Show(oOccPatt.Name, sNameParent)
	Next
End Function&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Jun 2023 13:16:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/how-to-get-the-inventor-occurrencepatternproxys-from-a-sub/m-p/12011831#M153489</guid>
      <dc:creator>Andrii_Humeniuk</dc:creator>
      <dc:date>2023-06-05T13:16:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the Inventor OccurrencePatternProxys from a sub assembly?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/how-to-get-the-inventor-occurrencepatternproxys-from-a-sub/m-p/12013611#M153526</link>
      <description>&lt;P&gt;I already tryed that but thought that it was not the right way, because the object I get back does not react to anything I would expect it to react to.&lt;/P&gt;&lt;P&gt;It does not react to visibility, suppression or adding it to selectSet. Example:&lt;/P&gt;&lt;P&gt;occPatt.Visibility = False&lt;/P&gt;&lt;P&gt;occPatt.Suppression()&lt;/P&gt;&lt;P&gt;This.Application.ActiveDocument.SelectSet.Select(occPatt)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I try visibility it goes throo without an error, but nothing happens.&lt;/P&gt;&lt;P&gt;When I try suppress it gives error: Public member 'Suppress' on type 'RectangularOccurrencePattern' not found.&lt;/P&gt;&lt;P&gt;When I try SelectSet.Select I get an error: The parameter is incorect&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jun 2023 05:54:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/how-to-get-the-inventor-occurrencepatternproxys-from-a-sub/m-p/12013611#M153526</guid>
      <dc:creator>jaka73LU2</dc:creator>
      <dc:date>2023-06-06T05:54:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the Inventor OccurrencePatternProxys from a sub assembly?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/how-to-get-the-inventor-occurrencepatternproxys-from-a-sub/m-p/12013685#M153528</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/12498327"&gt;@jaka73LU2&lt;/a&gt;&amp;nbsp;.&amp;nbsp;The visibility and suppression functions work perfectly, but SelectSet throws an error when trying to select items in a subassembly.&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="visual-basic"&gt;Private Sub Main()
	Dim oDoc As AssemblyDocument = ThisApplication.ActiveDocument
	Dim oColl As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
	Dim oDef As AssemblyComponentDefinition = oDoc.ComponentDefinition
	Call GetAllPatterns(oDef.OccurrencePatterns, oColl)
	Call GetAllOccs(oDef.Occurrences, oColl)
'	If oColl Is Nothing Then Exit Sub
'	Call oDoc.SelectSet.SelectMultiple(oColl)
'	oDoc.Rebuild()
'	oDoc.Update()
End Sub

Private Sub GetAllOccs(oOccs As ComponentOccurrences, ByRef oColl As ObjectCollection)
	For Each oOcc As ComponentOccurrence In oOccs
		If oOcc.Suppressed Then Continue For
		If oOcc.DefinitionDocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
			Dim oOccDef As AssemblyComponentDefinition = oOcc.Definition
			Dim oOccDoc As AssemblyDocument = oOccDef.Document
			If oOccDef.OccurrencePatterns.Count &amp;gt; 0 Then Call GetAllPatterns(oOccDef.OccurrencePatterns, oColl)
			If oOcc.SubOccurrences Is Nothing Then Continue For
			If oOcc.SubOccurrences.Count &amp;lt;&amp;gt; 0 Then
				Call GetAllOccs(oOcc.SubOccurrences, oColl)
			End If
		End If
	Next
End Sub

Private Function GetAllPatterns(oOccsPatt As OccurrencePatterns, ByRef oColl As ObjectCollection)
	For Each oOccPatt As OccurrencePattern In oOccsPatt
		
		' Work with visible
		oOccPatt.Visible = False
		MessageBox.Show(oOccPatt.Name &amp;amp; " - Visible", oOccPatt.Parent.Document.DisplayName)
		oOccPatt.Visible = True
		
		' Work with suppress
		oOccPatt.Suppress(True)
		MessageBox.Show(oOccPatt.Name &amp;amp; " - Suppress", oOccPatt.Parent.Document.DisplayName)
		oOccPatt.Unsuppress()
		
		'Select patterns
		oColl.Add(oOccPatt)
		
	Next
End Function&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also an example of working with the components of the opening subassembly:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;Private Sub Main()
	Dim oDoc As AssemblyDocument = ThisApplication.ActiveDocument
	Dim oDef As AssemblyComponentDefinition = oDoc.ComponentDefinition
	Call GetAllPatterns(oDef.OccurrencePatterns)
	Call GetAllOccs(oDef.Occurrences)
End Sub

Private Sub GetAllOccs(oOccs As ComponentOccurrences)
	For Each oOcc As ComponentOccurrence In oOccs
		If oOcc.Suppressed Then Continue For
		If oOcc.DefinitionDocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
			Dim oOccDef As AssemblyComponentDefinition = oOcc.Definition
			if oOccDef.OccurrencePatterns.Count &amp;gt; 0 then Call GetAllPatterns(oOccDef.OccurrencePatterns, oOcc)
			If oOcc.SubOccurrences Is Nothing Then Continue For
			If oOcc.SubOccurrences.Count &amp;lt;&amp;gt; 0 Then
				Call GetAllOccs(oOcc.SubOccurrences)
			End If
		End If
	Next
End Sub

Private Function GetAllPatterns(oOccsPatt As OccurrencePatterns, Optional oOcc As ComponentOccurrence = Nothing)
	If oOcc IsNot Nothing Then oOcc.Edit()
	For Each oOccPatt As OccurrencePattern In oOccsPatt
		MessageBox.Show(oOccPatt.Name, oOccPatt.Parent.Document.DisplayName)
	Next
	If oOcc IsNot Nothing Then oOcc.ExitEdit(ExitTypeEnum.kExitToParent)
End Function&lt;/LI-CODE&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;</description>
      <pubDate>Tue, 06 Jun 2023 06:49:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/how-to-get-the-inventor-occurrencepatternproxys-from-a-sub/m-p/12013685#M153528</guid>
      <dc:creator>Andrii_Humeniuk</dc:creator>
      <dc:date>2023-06-06T06:49:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the Inventor OccurrencePatternProxys from a sub assembly?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/how-to-get-the-inventor-occurrencepatternproxys-from-a-sub/m-p/12013914#M153532</link>
      <description>&lt;P&gt;I copied and pasted your code, but i am getting the same result.I would like to mention that I am making an AddIn so I slightly had to correct the code so a button is triggering the function.&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;Private Sub Button_test_Click(sender As Object, e As EventArgs) Handles Button_test.Click
        Try
            Dim oDoc As AssemblyDocument = g_inventorApplication.ActiveDocument
            Dim oColl As ObjectCollection = g_inventorApplication.TransientObjects.CreateObjectCollection
            Dim oDef As AssemblyComponentDefinition = oDoc.ComponentDefinition
            Call GetAllPatterns(oDef.OccurrencePatterns, oColl)
            Call GetAllOccs(oDef.Occurrences, oColl)

            If oColl Is Nothing Then Exit Sub

            For Each obj In oColl
                PrintToLog(obj.Name)
            Next

            oDoc.SelectSet.SelectMultiple(oColl)
            'oDoc.Rebuild()
            'oDoc.Update()

        Catch ex As Exception
            MsgBox(ex.ToString())
        End Try
    End Sub

    Private Sub GetAllOccs(oOccs As ComponentOccurrences, ByRef oColl As ObjectCollection)
        For Each oOcc As ComponentOccurrence In oOccs
            If oOcc.Suppressed Then Continue For
            If oOcc.DefinitionDocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
                Dim oOccDef As AssemblyComponentDefinition = oOcc.Definition
                Dim oOccDoc As AssemblyDocument = oOccDef.Document
                Call GetAllPatterns(oOccDef.OccurrencePatterns, oColl)
                If oOcc.SubOccurrences Is Nothing Then Continue For
                If oOcc.SubOccurrences.Count &amp;lt;&amp;gt; 0 Then
                    Call GetAllOccs(oOcc.SubOccurrences, oColl)
                End If
            End If

            oColl.Add(oOcc)
        Next
    End Sub

    Private Function GetAllPatterns(oOccsPatt As OccurrencePatterns, ByRef oColl As ObjectCollection)
        For Each oOccPatt As OccurrencePattern In oOccsPatt

            ' Work with visible
            oOccPatt.Visible = False

            ' Work with suppress
            oOccPatt.Suppress(True)

            'Select patterns
            oColl.Add(oOccPatt)

        Next
    End Function&lt;/LI-CODE&gt;&lt;P&gt;If I leave the line where it should suppress the patterns it gives an error: Public member 'Suppress' on type 'RectangularOccurrencePattern' not found.&lt;/P&gt;&lt;P&gt;If I comment out that line it gives an error at the 'SelectSet.SelectMultiple' where it gives an error: The parameter is incorrect.&lt;/P&gt;&lt;P&gt;The visibility line is ignored every time.&lt;/P&gt;&lt;P&gt;I need to point out that this problem persists only on lower level patterns. If I only look for top level patterns it works fine as expected.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jun 2023 08:49:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/how-to-get-the-inventor-occurrencepatternproxys-from-a-sub/m-p/12013914#M153532</guid>
      <dc:creator>jaka73LU2</dc:creator>
      <dc:date>2023-06-06T08:49:17Z</dc:date>
    </item>
  </channel>
</rss>

