09-07-2023
11:11 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
09-07-2023
11:11 PM
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