Get list all part that has got a derived component

Get list all part that has got a derived component

ngdnam88
Advocate Advocate
295 Views
2 Replies
Message 1 of 3

Get list all part that has got a derived component

ngdnam88
Advocate
Advocate

Dears,

I'm working in some part with derived component. Please help me iLogic/VB.NET code that can get list of all part that has got a derived component. I wanna open all these part to update some thing automatic.

Thanks you!

0 Likes
296 Views
2 Replies
Replies (2)
Message 2 of 3

A.Acheson
Mentor
Mentor

You will need to look at reference components. See API help here and forum sample here.

Syntax

PartComponentDefinition.ReferenceComponents() As ReferenceComponents

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 3 of 3

kriegler
Contributor
Contributor

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