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

Sorry, yesterday must have been some spots on sun or something. Here is updated version of IsActiveByPartNumber. When the component is suppressed, you can't read its definition. Component must be activated before.

Sub IsActiveByPartNumber(asm As AssemblyDocument, isActive As Boolean, ParamArray partNumbers() As String)

    'Get occurrences to process by its document PartNumber
    Dim occList As New List(Of ComponentOccurrence)

    For Each occ As ComponentOccurrence In asm.ComponentDefinition.Occurrences
        Dim isActiveBefore = Component.IsActive(occ.Name)
        If Not isActiveBefore Then
            Component.IsActive(occ.Name) = True
        End If

        Dim doc As Document = occ.Definition.Document
        Dim partNumber As String = doc.PropertySets("{32853F0F-3444-11D1-9E93-0060B03C1CA6}")("Part Number").Value
        If partNumbers.Contains(partNumber) Then
            occList.Add(occ)
        ElseIf Not isActiveBefore Then
            Component.IsActive(occ.Name) = False
        End If
    Next

    'Do something with occurrences in list
    For Each occ In occList
        Component.IsActive(occ.Name) = isActive
    Next
End Sub