By Adam Nagy
If you need to get back occurrences with certain name patterns, then you just have to iterate through them and check their name. Depending on how many levels you want to check you could also use the AllLeafOccurrences property, like in this iLogic sample code that can be run inside an assembly document:
Sub Main Dim ocs = OccurrencesWhereNameStartsWith( ThisDoc.Document.ComponentDefinition, "RC") Dim msg As String Dim oc For Each oc In ocs msg = msg + oc.Name + vbCrLf Next MsgBox(msg) End Sub Function OccurrencesWhereNameStartsWith( _ acd As AssemblyComponentDefinition, str As String) _ As ObjectCollection Dim oc As ObjectCollection oc = ThisApplication.TransientObjects.CreateObjectCollection() Dim co As ComponentOccurrence For Each co In acd.Occurrences.AllLeafOccurrences If co.Name.StartsWith(str) Then oc.Add (co) End If Next Return oc End Function