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

Hi @floccipier 

If you dont want to use a for each loop and just loop through the occurrences, checking each one of them if it's visible or not and add +1 to an integer if so, you can do it like this :slightly_smiling_face: (oDoc = the document your'e checking all referenced occurrences of)

Dim oAsm As AssemblyDocument = ThisDoc.Document
MsgBox(oAsm.ComponentDefinition.Occurrences.AllReferencedOccurrences(oDoc).OfType(Of ComponentOccurrence).Where(Function(x) x.Visible = True).Count)

Otherwise something like this is probably the most simple way to do it:

Dim oAsm As AssemblyDocument = ThisDoc.Document
Dim count As Integer = 0
For Each oOcc As ComponentOccurrence In oAsm.ComponentDefinition.Occurrences.AllReferencedOccurrences(oDoc)
	If oOcc.Visible Then count += 1
Next
MsgBox(count)