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

How to read all component in assembly

abilabib
Advocate

How to read all component in assembly

abilabib
Advocate
Advocate

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

 

0 Likes
Reply
Accepted solutions (1)
388 Views
2 Replies
Replies (2)

chandra.shekar.g
Autodesk Support
Autodesk Support
Accepted solution

@abilabib,

 

Hoping that below forum link would help

 

https://forums.autodesk.com/t5/inventor-customization/apprenticeservercomponent-replacereference-err...

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes

abilabib
Advocate
Advocate

@chandra.shekar.g : Thanks for your reply. 

0 Likes