Hi @tecnico. Here is something you can try for that task. First, it makes sure it is working with an assembly (not a part or drawing). Then it gets the components collection. Then iterates through them, skipping any that are suppressed, and if a 'virtual' one is found, it compares the first part of that components name to the DisplayName of the main assembly. If a match is found, a message will pop-up and let you know.
Sub Main
If ThisDoc.Document.DocumentType <> DocumentTypeEnum.kAssemblyDocumentObject Then
MsgBox("An Assembly Document must be active for this rule to work. Exiting.", vbCritical, "")
Exit Sub
End If
Dim oADoc As AssemblyDocument = ThisDoc.Document
Dim oOccs As ComponentOccurrences = oADoc.ComponentDefinition.Occurrences
For Each oOcc As ComponentOccurrence In oOccs
If oOcc.Suppressed Then Continue For 'cant access Definition if Suppressed
If TypeOf oOcc.Definition Is VirtualComponentDefinition Then
If oOcc.Name.StartsWith(oADoc.DisplayName) Then
MsgBox("Found a Virtual component with same name as main assembly.", vbInformation, "iLogic")
End If
End If
Next 'oOcc
End Sub
If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) 👍.
Wesley Crihfield

(Not an Autodesk Employee)