09-05-2023
11:20 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
09-05-2023
11:20 PM
You can create your own collection of occurrences to do something with them. You can also separate the selection process to separate method.
Dim asm As AssemblyDocument = ThisDoc.Document
Dim lookedPartNumber As String = "MyPartNumber"
Dim isActive As Boolean = False
'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 doc As Document =occ.Definition.Document
Dim partNumber As String = doc.PropertySets("{32853F0F-3444-11D1-9E93-0060B03C1CA6}")("Part Number").Value
If partNumber = lookedPartNumber Then
occList.Add(occ)
End If
Next
'Do something with occurrences in list
For Each occ In occList
Component.IsActive(occ.Name) = isActive
Next