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

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