Hi @Henryk_Konczylo
How about something like this? 🙂
Run this rule in the drawing. The rule will prompt you to pick a view and then return a list as described by you 🙂
Dim oView As DrawingView = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter, "Pick view")
If oView Is Nothing Then Exit Sub
Dim sumString As String = "Components in view " & oView.Name & ":" & vbCrLf
Dim oDoc As Document = oView.ReferencedDocumentDescriptor.ReferencedDocument
If oDoc.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
For Each oRefDoc As Document In oDoc.AllReferencedDocuments
Dim oCount As Integer = oDoc.ComponentDefinition.Occurrences.AllReferencedOccurrences(oRefDoc).Count
If oCount > 0 Then
sumString = sumString & vbCrLf & IO.Path.GetFileNameWithoutExtension(oRefDoc.DisplayName) & " -> " & oCount
End If
Next
Else
MsgBox("view doesn't reference an assembly")
Exit Sub
End If
MessageBox.Show(sumString, "Occurrence count")