Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
jaka73LU2
in reply to: Andrii_Humeniuk

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.

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 <> 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

If I leave the line where it should suppress the patterns it gives an error: Public member 'Suppress' on type 'RectangularOccurrencePattern' not found.

If I comment out that line it gives an error at the 'SelectSet.SelectMultiple' where it gives an error: The parameter is incorrect.

The visibility line is ignored every time.

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.