Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
abilabib
386 Views, 2 Replies

How to read all component in assembly

How to read all component if we use apprentice.

We can read all document if we use AllReferencedDocuments. But I don't see option for replace component in this mode.  But we can replace component if use ReferencedDocumentDescriptors. But in this mode just read all component in level 1. 

Please tell me how to read all component in referenced document or how to replace component in All Referenced Document.  

 

Here's my code. 

 

Sub ReplaceComponent()
        ' Create an instance of Apprentice.
        Dim apprentice As New Inventor.ApprenticeServerComponent
        ' Open a document.
        Dim doc As Inventor.ApprenticeServerDocument
        doc = apprentice.Open(FilePath)
        'Me-Replace component
        For Each docDes As Inventor.DocumentDescriptor In doc.ReferencedDocumentDescriptors
            Console.WriteLine(docDes.ReferencedFileDescriptor.FullFileName)
            'If docDes.ReferencedFileDescriptor.FullFileName = OldName Then
            '    Console.WriteLine("-->" & NewName)
            '    'docDes.ReferencedFileDescriptor.ReplaceReference(newPartFile)
            '    'fileSave.AddFileToSave(NewDoc, NewDoc.FullFileName)
            '    'fileSave.ExecuteSave()
            '    'Return
            'End If
        Next
    End Sub