Message 1 of 26
Acquire Vault Files with Inventor API
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi!
I'm looking for a way to 'Get' files from the Vault with iLogic
What I have so far:
All my wanted files are in a VBA Dictionary stored as Filename.extension
Imports System.Text Imports System.IO 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 "Connectivity.Application.VaultBase.dll" AddReference "Autodesk.Connectivity.WebServices.dll"
For i = 0 To oTotalDict.Count - 1 'oTotalDict(String(C:/path/.../filename.extension), Int(QTY)) 'oCount = oTotalDict.Values(i) Key = oTotalDict.Keys(i) dwgPath = Left(key, Len(Key) - 3) & "dwg" VaultPartPath = Key.Replace("C:\Company\Vault\", "$/") VaultPartPath = VaultPartPath.Replace("\", "/") VaultDWGPath = dwgPath.Replace("C:\Company\Vault\", "$/") VaultDWGPath = VaultDWGPath.Replace("\", "/") Dim VaultDWGPaths() As String = New String() {VaultDWGPath } Dim VaultPartPaths() As String = New String() {VaultPartPath } Dim wsFiels() As AWS.File = mVltCon.WebServiceManager.DocumentService.FindLatestFilesByPaths(VaultDWGPaths) Dim wsFiels2() As AWS.File = mVltCon.WebServiceManager.DocumentService.FindLatestFilesByPaths(VaultPartPaths) 'Ts file exists in the Vault. Dim DwgFileIt As VDF.Vault.Currency.Entities.FileIteration = New VDF.Vault.Currency.Entities.FileIteration(conn, wsFiels(0)) 'DWG HERE Dim PartFileIt As VDF.Vault.Currency.Entities.FileIteration = New VDF.Vault.Currency.Entities.FileIteration(conn, wsFiels2(0)) 'PART HERE (IPT/IAM) Dim lifeCycleInfo As VDF.Vault.Currency.Entities.FileLifecycleInfo = DwgFileIt.LifecycleInfo Dim DWGIsCheckedOut As Boolean = DwgFileIt.IsCheckedOut Dim PartIsCheckedOut As Boolean = PartFileIt.IsCheckedOut If DWGIsCheckedOut = True Trace.WriteLine("CHECKED OUT: " & dwgPath) Else If PartIsCheckedOut = True Trace.WriteLine("CHECKED OUT: " & Key) End If If Not lifeCycleInfo.StateId = - 1 'IN VAULT 'Trace.WriteLine("File not in C?: " & dwgPath) If System.IO.File.Exists(dwgPath) 'Trace.WriteLine("YES IN VAULT, YES ON C: " & dwgPath & " Status: " & lifeCycleInfo.StateName)' & " ID:" & lifeCycleInfo.StateId) End If If Not System.IO.File.Exists(dwgPath) Trace.WriteLine("YES IN VAULT, NOT ON C: " & dwgPath & " Status: " & lifeCycleInfo.StateName)' & " ID:" & lifeCycleInfo.StateId) End If End If If lifeCycleInfo.StateId = - 1 'FILE NOT IN VAULT. 'Trace.WriteLine("File not in Vault?: " & dwgPath) If System.IO.File.Exists(dwgPath) Trace.WriteLine("ON C, NOT IN VAULT: " & dwgPath & " Status: " & lifeCycleInfo.StateName)' & " ID:" & lifeCycleInfo.StateId) End If If Not System.IO.File.Exists(dwgPath) 'Trace.WriteLine("NOT ON C, NOT IN VAULT: " & dwgPath & " Status: " & lifeCycleInfo.StateName)' & " ID:" & lifeCycleInfo.StateId) End If End If 'MessageBox.Show(lifeCycleInfo.StateName) Next
I want to get the files that are not on C but are located in the Vault.
I found some topics that might be interesting but I don't know how to get the files themselves yet.
https://forums.autodesk.com/t5/inventor-customization/ilogic-open-file-from-vault/td-p/5701827
Anyone that knows how to get a file from vault just from the fullpathname?
The Vault API Help gives this example but I don't know how to use it.
Imports VDF = Autodesk.DataManagement.Client.Framework Public Sub DownlodFiles(fileIters As ICollection(OfVDF.Vault.Currency.Entities.FileIteration)) ' download individual files to a temp location Dim settings As NewVDF.Vault.Settings.AcquireFilesSettings(m_conn) settings.LocalPath = NewVDF.Currency.FolderPathAbsolute("c:\temp") For Each fileIter AsVDF.Vault.Currency.Entities.FileIteration In fileIters settings.AddFileToAcquire(fileIter, _ _ VDF.Vault.Settings.AcquireFilesSettings.AcquisitionOption.Download) Next Dim results As VDF.Vault.Results.AcquireFilesResults = _ m_conn.FileManager.AcquireFiles(settings) End Sub Public Sub DownloadAssembly(topLevelAssembly AsVDF.Vault.Currency.Entities.FileIteration) ' download the latest version of the assembly to working folders Dim settings As NewVDF.Vault.Settings.AcquireFilesSettings(m_conn) settings.OptionsRelationshipGathering.FileRelationshipSettings.IncludeChildren = True settings.OptionsRelationshipGathering.FileRelationshipSettings.RecurseChildren = True settings.OptionsRelationshipGathering.FileRelationshipSettings.VersionGatheringOption = _ VDF.Vault.Currency.VersionGatheringOption.Latest settings.AddFileToAcquire(topLevelAssembly, _ VDF.Vault.Settings.AcquireFilesSettings.AcquisitionOption.Download) Dim results As VDF.Vault.Results.AcquireFilesResults = _ m_conn.FileManager.AcquireFiles(settings) End Sub Public Sub DownloadDialog(fileIter AsVDF.Vault.Currency.Entities.FileIteration, _ parentWindowHandle As IntPtr) ' pop up the Get/Checkout dialog Dim settings As NewVDF.Vault.Forms.Settings.InteractiveAcquireFileSettings( _ m_conn, parentWindowHandle, "Download files") settings.AddEntityToAcquire(fileIter) VDF.Vault.Forms.Library.AcquireFiles(settings) End Sub
Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.
___________________________