Hi @Anonymous
Here are a couple of examples.
Note that you can search and ask programming questions of this type on the Inventor Customization forum:
http://forums.autodesk.com/t5/Autodesk-Inventor-Customization/bd-p/120
Find Unresolved components
Sub main
Dim oFile As Inventor.File
oFile = ThisApplication.ActiveDocument.File
Dim oDoc As AssemblyDocument
oDoc = ThisApplication.ActiveDocument
Dim oDocDef As AssemblyComponentDefinition
oDocDef = oDoc.ComponentDefinition
Call FindUnresolved(oFile, oDoc, oDocDef)
End Sub
Sub FindUnresolved(ByVal oFile As Inventor.File, oDoc As AssemblyDocument, oDocDef As ComponentDefinition)
Dim oSelection As SelectSet
oSelection = oDoc.SelectSet
oSelection.Clear
Dim oCollection As ObjectCollection
oCollection = ThisApplication.TransientObjects.CreateObjectCollection
Dim oFileDescriptor As FileDescriptor
For Each oFileDescriptor In oFile.ReferencedFileDescriptors
If Not oFileDescriptor.ReferenceMissing Then
If Not oFileDescriptor.ReferencedFileType = FileTypeEnum.kForeignFileType Then
Call FindUnresolved(oFileDescriptor.ReferencedFile, oDoc, oDocDef)
End If
Else
Dim oOccurrence As ComponentOccurrence
For Each oOccurrence In oDocDef.Occurrences.AllLeafOccurrences
If oOccurrence.ReferencedDocumentDescriptor.ReferencedFileDescriptor.FullFileName _
= oFileDescriptor.FullFileName Then
oCollection.Add(oOccurrence)
End If
Next oOccurrence
End If
Next
oSelection.SelectMultiple(oCollection)
End Sub
Select grounded components
Dim oDoc As AssemblyDocument
oDoc = ThisApplication.ActiveDocument
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = oDoc.ComponentDefinition
Dim oSelection As SelectSet
oSelection = oDoc.SelectSet
oSelection.Clear
Dim oCollection As ObjectCollection
oCollection = ThisApplication.TransientObjects.CreateObjectCollection
Dim oOccurrence As ComponentOccurrence
For Each oOccurrence In oAsmCompDef.Occurrences
If oOccurrence.Grounded = True Then
oCollection.Add(oOccurrence)
End If
Next
oSelection.SelectMultiple(oCollection)