Here my solution,
''' <summary>
''' Returns all PartDocuments in an Assembly which have DerivedComponents
''' </summary>
Public Sub AllDocumentsWithDerivedComponent()
Dim locAktivDoc As Inventor.Document = InventorApplication.ActiveDocument
Dim locAssemblyDoc As Inventor.AssemblyDocument
If locAktivDoc.DocumentType = Inventor.DocumentTypeEnum.kAssemblyDocumentObject Then
locAssemblyDoc = CType(InventorApplication.ActiveDocument, Inventor.AssemblyDocument)
Else
Return
End If
Dim retList As IOrderedEnumerable(Of Inventor.Document) = locAssemblyDoc.AllReferencedDocuments.Cast(Of Inventor.Document).
Where(Function(x) x.DocumentType = Inventor.DocumentTypeEnum.kPartDocumentObject AndAlso
(CType(x, Inventor.PartDocument).ComponentDefinition.ReferenceComponents.DerivedPartComponents.Count > 0 OrElse
CType(x, Inventor.PartDocument).ComponentDefinition.ReferenceComponents.DerivedAssemblyComponents.Count > 0)).
OrderBy(Function(x) x.FullFileName)
'The same but without sorting
'Dim retList As IEnumerable(Of Inventor.Document) = m_AssemblyDocument._document.AllReferencedDocuments.Cast(Of Inventor.Document).
' Where(Function(x) x.DocumentType = Inventor.DocumentTypeEnum.kPartDocumentObject AndAlso
' (CType(x, Inventor.PartDocument).ComponentDefinition.ReferenceComponents.DerivedPartComponents.Count > 0 OrElse
' CType(x, Inventor.PartDocument).ComponentDefinition.ReferenceComponents.DerivedAssemblyComponents.Count > 0))
'Do somthing
For Each tempdoc As Inventor.Document In retList
Dim partDoc As Inventor.PartDocument = CType(tempdoc, Inventor.PartDocument)
TextBoxResult.AppendText(partDoc.FullFileName & vbNewLine)
Next
End Sub
If this solved a problem, please click (accept) as solution.
Or if this helped you, please, click (like)
Regards
Johann