How to read all component in assembly

How to read all component in assembly

abilabib
Advocate Advocate
445 Views
2 Replies
Message 1 of 3

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
Accepted solutions (1)
446 Views
2 Replies
Replies (2)
Message 2 of 3

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
Message 3 of 3

abilabib
Advocate
Advocate

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

0 Likes