By Barbara Han
Before Inventor 10 (including) the ReferenceFileDescriptor.PutCustomLogicalUsingFull was the method used to replace the file reference and this method was only allowed in Apprentice on non-migrating data sets.
But after Inventor 10, there is a new object called file object is introduced, where each File object will contain one or more documents. Now document is not the same as file anymore where the documents are still represented by the various document objects. So, hereafter instead of using ReferenceFileDescriptor.PutLogicalFilenameUsingFull we need to use FileDescriptor.ReplaceReference.
Significantly, FileDescriptor.ReplaceReference is available inside Inventor as well as in Apprentice.
Following is a part of VBA code which shows how to use the FileDescriptor.ReplaceReference with apprentice API:
Dim oApprentice As ApprenticeServerComponent
Set oApprentice = New ApprenticeServerComponent
Dim oADoc As ApprenticeServerDocument
Set oADoc = oApprentice.Open("C:\Assembly1.iam")
Dim oFD As FileDescriptor
Set oFD = oADoc.File.ReferencedFileDescriptors(1)
Call oApprentice.FileSaveAs.AddFileToSave(oADoc, oADoc.FullFileName)
And this is a part of VBA code that does the same with Inventor API:
Dim oDoc As Inventor.DrawingDocument
Set oDoc = ThisApplication.Documents.Open("C:\Assembly1.iam")
Note: For a file to be valid as a replacement it must have the same heritage as the file being replaced. You cannot replace a file with a brand new file. It has to be copied or modified from the already existing file - they must have shared the same ancestor in their past.