Create this external rule called "Get From Vault Function"
Imports Autodesk.DataManagement.Client.Framework.Vault
Imports Autodesk.Connectivity.WebServices
Imports VDF = Autodesk.DataManagement.Client.Framework
Imports ACW = Autodesk.Connectivity.WebServices
Imports AWS = Autodesk.Connectivity.WebServices
Imports VB = Connectivity.Application.VaultBase
Imports Autodesk.DataManagement.Client.Framework.Vault.Currency'.Properties
AddReference "Autodesk.DataManagement.Client.Framework.Vault.dll"
AddReference "Autodesk.DataManagement.Client.Framework.dll"
AddReference "Connectivity.Application.VaultBase.dll"
AddReference "Autodesk.Connectivity.WebServices.dll"
Dim oFilePath As String = RuleArguments("oFilePath")
Dim oVaultConnection As VDF.Vault.Currency.Connections.Connection
oVaultConnection = VB.ConnectionManager.Instance.Connection
If oVaultConnection Is Nothing Then
MessageBox.Show("Not Logged In to Vault! - Login first and repeat executing this rule.")
Exit Sub
End If
VaultPath = oFilePath.Replace("D:\Working Folder\", "$/")
VaultPath = VaultPath.Replace("\", "/")
SplitPath = oFilePath.Split("\")
FolderPath = SplitPath(0) & "\"
For i = 1 To SplitPath.Length - 2
FolderPath = FolderPath & SplitPath(i) & "\"
Next
Dim VaultPaths() As String = New String() {VaultPath }
Dim wsFiels() As AWS.File = oVaultConnection.WebServiceManager.DocumentService.FindLatestFilesByPaths(VaultPaths)
Dim mFileIt As VDF.Vault.Currency.Entities.FileIteration = New VDF.Vault.Currency.Entities.FileIteration(oVaultConnection,wsFiels(0))
Dim oSettings As New VDF.Vault.Settings.AcquireFilesSettings(oVaultConnection)
oSettings.LocalPath = New VDF.Currency.FolderPathAbsolute(FolderPath)
oSettings.AddFileToAcquire(mFileIt, VDF.Vault.Settings.AcquireFilesSettings.AcquisitionOption.Download)
Try
Dim oResults As VDF.Vault.Results.AcquireFilesResults = oVaultConnection.FileManager.AcquireFiles(oSettings)
RuleArguments.Arguments.Value("Success") = True
Catch
RuleArguments.Arguments.Value("Success") = False
End Try
then put this in your local rule:
oFilePath = "you part to get from vault Full filename.ipt"
Dim oRuleArguments As Inventor.NameValueMap = ThisApplication.TransientObjects.CreateNameValueMap()
oRuleArguments.Add("oFilePath",oFilePath)
iLogicVb.RunExternalRule("Get From Vault Function", oRuleArguments)
'this returns True/False depending on whether download was successful or not.
Dim oFileDownloadedSuccessfully As String = oRuleArguments.Item("Success")
'MessageBox.Show(oFilePath, oFileDownloadedSuccessfully)
'use this line before checking for other files
oRuleArguments.Clear
If you want to refresh from vault, i delete off my local first, and then run this rule.
regards
Mark