By Barbara Han
From Vault Explorer or Inventor, you can map local folder (e.g. C:\Cad\parts) to Vault folder (e.g. $\StandardParts) through using Map Folders command under Access panel in Vault ribbon tab in Inventor. Is it possible to get the mapped local folder path through API? I would need this to know where I have to store Files downloaded via the Vault method “downloadFile(...)” (Storing it under the wrong path results in Vault not working correctly).
You can call DesignProject.VirtualVaultPath from Inventor API to get the mapped Vault folder information, as shown in below picture:
Once the mapped Vault folder information is set up, call GetWorkingFolder from Vault API to get the local path for the mapped Vault folder (e.g. above displayed “$/ProjectName1”).
GetWorkingFolder() is provided by IExplorerUtil interface from Autodesk.Connectivity.Explorer.Extensibility.dll. IExplorerUtil interface can be achieved by ExplorerLoader.GetExplorerUtil or ExplorerLoader.LoadExplorerUtil. For more detailed information, please see Vault API help document. The following is the sample code snippet:
This function has a problem in Vault 2012 shipping release and there is a fix available for download on Doug Redmond’s blog:
“2 API-Related Hotfixes”
Another thing that needs to be handled is, if the Vault cleint is set up with the enforced working folder, then the GetEnforceWorkingFolder API would return true, you then should Call GetRequiredWorkingFolderLocation to retrieve the real mapped folder path, instead of using the information from WorkingFolders.xml because the later doesn’t help in this case.
For versions older than Inventor 2011, there is no DesignProject.VirtualVaultPath API that returns the mapped Vault folder set in the Inventor project. Let’s look at a workaround descript as the following:
The correct place to get the Vault mapped folder is to read the Inventor’s IPJ file for Inventor IPJ file contains the mapping between Vault path and local workspace path.? Inventor project file is XML format, so you can rename .ipj file to .xml file then read/edit the file. If the project is Vault project, then you will find VaultOptions node in the project file, if the mapping path exist, you will see , you will see VaultVirtualFolder such as the following:
However the .ipj file format might be subject to any change in future releases without notice (so that we don’t officially publish its format). We don’t support direct access to the .ipj file. Please note that my above suggestion might be no longer able to work in future release.
With Vault 2011 and older versions, there is no GetWorkingFolder API. The following describes a workaround that can get the mapped folder information by indirect way:
The Vault to local folder mapping can be found in a file called WorkingFolders.xml. Actually there can be several of these files. Different users/servers/vaults cause more of these files to pop up. Here is the path:
C:\Documents and Settings\[Windows user]\Application Data\Autodesk\VaultCommon\Servers\[ADMS Version]\[Server]\Vaults\[Vault Name]\Objects
C:\Documents and Settings\Administrator\Application Data\Autodesk\VaultCommon\Servers\Services_Security_01_17_2008\localhost\Vaults\Vault\Objects
- Administrator: The Windows user
- Services_Security_01_17_2008: The signature (version) of the security service. (1/17/2008 = ADMS 2009)
- Localhost: The vault server location
- Vault: The name of the Vault
Please only read this file. Don’t edit it. The customized application can read in this file and figure out where to copy the files so that they show up in the correct spot when the user fires up Vault Explorer.