- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi @shrey9GP3F. I am not fluent in C#, but it looks to me like the code posted here is missing a step. In line 4, it looks like you are attempting to get 'ReferencedFileDescriptors' directly from a Document object (oDoc), but I believe you need to get the document's 'File', before you can then get that File.ReferencedFileDescriptors. So, I believe you would need to replace this:
foreach (Inventor.FileDescriptor oFileDesc in oDoc.ReferencedFileDescriptors)
...with this:
foreach (Inventor.FileDescriptor oFileDesc in oDoc.File.ReferencedFileDescriptors)
However, if there are ModelStates involved, and you want to maintain each view's reference to the equivalent ModelState of the replacement model, then you may have to iterate each view, on each sheet, and replace its reference individually.
DrawingView.ReferencedDocumentDescriptor.ReferencedFileDescriptor.ReplaceReference(sReplacementFileName)
That way you can extract the originally specified ModelState name (or iPart/iAssembly Member name) before the replacement, then set it back after the replacement, to maintain it. Each DrawingView object has a property named ActiveMemberName, which records which iPart/iAssembly member it is set to, and a property named ActiveModelState, which obviously records which ModelState it is set to. But the ActiveModelState property is ReadOnly, so you would have to use the DrawingView.SetActiveModelState method to set the value back to the view after the replacement.
Wesley Crihfield
(Not an Autodesk Employee)