ReplaceReference vs FileSaveAs vs OnFileResolution

By Adam Nagy

There are multiple ways of dealing with moving and renaming Inventor documents and updating the references to them; so that all the relevant files can be found when your design is opened in Inventor.

1) ReplaceReference

Available in Inventor and Apprentice  

This requires that the file originally referenced will have the same ancestry as the new file the reference is being changed to. So the files do not have to be exactly the same: the new file could be a modified version of the original.

Note: This does not seems to work well in all scenarios. E.g. in case of special assembly components like Cable & Harness assembly's part component, it won't work. Also, inside Apprentice you cannot save a file that needs migration (ApprenticeServerDocument.NeedsMigrating = true)

2) FileSaveAs

Available in Apprentice only

This functionality helps you change the name and path of a file and also updates all the references to it. Obviously, in this case the original file and the newly saved file will be exactly the same. Maybe that's why it's more robust and seems to work with any files.  

The "Copy Design" sample of the Inventor SDK shows how to use it: "C:\Users\Public\Documents\Autodesk\Inventor 2016\SDK\UserTools\CopyDesign" (you have to install "usertools.msi" first) 

Note: if the file needs migration (ApprenticeServerDocument.NeedsMigrating = true) then the FileSaveAs approach won't work. Also read Using Apprentice from VBA, iLogic or an Add-In 

3) OnFileResolution

Available in Inventor only

If Inventor cannot find a file when your document is opened then it will pop up a "Resolve Link" dialog.

ResolveLink

Its API equivalent is the call to the OnFileResolution event of the FileAccessEvents object. This event fires for all the files that Inventor needs, even if the referenced files were not moved or renamed. This also seems to work for all documents. 


Comments

2 responses to “ReplaceReference vs FileSaveAs vs OnFileResolution”

  1. Frank Hall Avatar
    Frank Hall

    2) SaveFileAs
    Quote “This functionality helps you change the name and path of a file and also updates all the references to it.”
    How can this file know which other files are referencing it? Its really a question of ‘Parent’ files and ‘Child’ files but I don’t believe this functions in this way at all.

  2. It only updates the references in the files which have also been added for save inside Apprentice.

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading