Hello,
I'm trying to open a part file from Vault (using an Inventor addin made in VB.net)
I've seen various samples but I can't find the last part, which is to open the file.
I'm at the point where I can download the file and I could get Vaultpath but to open it I need to know where it is placed locally.
I can't find anything about finding where a file is placed using AcquireFiles.
Is there any way of knowing that?
My code so far:
Imports Autodesk.Connectivity.WebServices
Module OpenNumberFromVault
Private _inventorApplication As Global.Inventor.Application
Private mVltCon As Autodesk.DataManagement.Client.Framework.Vault.Currency.Connections.Connection
Public Sub OpenNumberFromVaultSub()
'Get the current Vault connection
mVltCon = Connectivity.Application.VaultBase.ConnectionManager.Instance.Connection()
'Declare variables needed for a Vaultsearch
Dim searchcondition As New SrchCond
Dim bookmark As String = String.Empty
Dim status As SrchStatus = Nothing
Dim searchstring As String
'Use an inputbox to have the user fill in the desired partnumber
searchstring = InputBox("Enter number", "Open part from Vault")
'Define the needed searchoptions
searchcondition.PropDefId = 8
searchcondition.PropTyp = PropertySearchType.SingleProperty
searchcondition.SrchOper = 1
searchcondition.SrchTxt = searchstring
Dim SrcConds(0) As SrchCond
SrcConds(0) = searchcondition
'Search Vault
Dim files As File() = mVltCon.WebServiceManager.DocumentService.FindFilesBySearchConditions(SrcConds, Nothing, Nothing, True, True, bookmark, status)
Dim PartFile As File
'Check if there was anything found, if not tell the user
If files Is Nothing Then
MessageBox.Show("Not found")
Else
'Look for the .ipt file in the results
For Each FileFound As File In files
If Strings.Right(FileFound.Name, 3) = "ipt" Then
PartFile = FileFound
End If
Next
'Check if there was an .ipt found, it could be there is an .iam of the file in the Vault instead of an .ipt
If PartFile Is Nothing Then
MessageBox.Show("No partfile of that number found in Vault")
Else
'Download the file
Dim settings As New Autodesk.DataManagement.Client.Framework.Vault.Settings.AcquireFilesSettings(mVltCon)
Dim FileToDownload As File = PartFile
Dim FileIteration As Autodesk.DataManagement.Client.Framework.Vault.Currency.Entities.FileIteration = New Autodesk.DataManagement.Client.Framework.Vault.Currency.Entities.FileIteration(mVltCon, FileToDownload)
settings.AddFileToAcquire(FileIteration, Autodesk.DataManagement.Client.Framework.Vault.Settings.AcquireFilesSettings.AcquisitionOption.Download)
mVltCon.FileManager.AcquireFiles(settings)
'Open the file
Dim VaultFolder As Autodesk.DataManagement.Client.Framework.Vault.Currency.Entities.Folder
VaultFolder = mVltCon.FolderManager.GetFoldersByIds({PartFile.FolderId}).First.Value
'_inventorApplication.Documents.Open(Folderpath & File)
End If
End If
End Sub
End Module
All the examples already have the folderpath because they use an open Inventor document or download to a temp folder.
Solved! Go to Solution.
Hello,
I'm trying to open a part file from Vault (using an Inventor addin made in VB.net)
I've seen various samples but I can't find the last part, which is to open the file.
I'm at the point where I can download the file and I could get Vaultpath but to open it I need to know where it is placed locally.
I can't find anything about finding where a file is placed using AcquireFiles.
Is there any way of knowing that?
My code so far:
Imports Autodesk.Connectivity.WebServices
Module OpenNumberFromVault
Private _inventorApplication As Global.Inventor.Application
Private mVltCon As Autodesk.DataManagement.Client.Framework.Vault.Currency.Connections.Connection
Public Sub OpenNumberFromVaultSub()
'Get the current Vault connection
mVltCon = Connectivity.Application.VaultBase.ConnectionManager.Instance.Connection()
'Declare variables needed for a Vaultsearch
Dim searchcondition As New SrchCond
Dim bookmark As String = String.Empty
Dim status As SrchStatus = Nothing
Dim searchstring As String
'Use an inputbox to have the user fill in the desired partnumber
searchstring = InputBox("Enter number", "Open part from Vault")
'Define the needed searchoptions
searchcondition.PropDefId = 8
searchcondition.PropTyp = PropertySearchType.SingleProperty
searchcondition.SrchOper = 1
searchcondition.SrchTxt = searchstring
Dim SrcConds(0) As SrchCond
SrcConds(0) = searchcondition
'Search Vault
Dim files As File() = mVltCon.WebServiceManager.DocumentService.FindFilesBySearchConditions(SrcConds, Nothing, Nothing, True, True, bookmark, status)
Dim PartFile As File
'Check if there was anything found, if not tell the user
If files Is Nothing Then
MessageBox.Show("Not found")
Else
'Look for the .ipt file in the results
For Each FileFound As File In files
If Strings.Right(FileFound.Name, 3) = "ipt" Then
PartFile = FileFound
End If
Next
'Check if there was an .ipt found, it could be there is an .iam of the file in the Vault instead of an .ipt
If PartFile Is Nothing Then
MessageBox.Show("No partfile of that number found in Vault")
Else
'Download the file
Dim settings As New Autodesk.DataManagement.Client.Framework.Vault.Settings.AcquireFilesSettings(mVltCon)
Dim FileToDownload As File = PartFile
Dim FileIteration As Autodesk.DataManagement.Client.Framework.Vault.Currency.Entities.FileIteration = New Autodesk.DataManagement.Client.Framework.Vault.Currency.Entities.FileIteration(mVltCon, FileToDownload)
settings.AddFileToAcquire(FileIteration, Autodesk.DataManagement.Client.Framework.Vault.Settings.AcquireFilesSettings.AcquisitionOption.Download)
mVltCon.FileManager.AcquireFiles(settings)
'Open the file
Dim VaultFolder As Autodesk.DataManagement.Client.Framework.Vault.Currency.Entities.Folder
VaultFolder = mVltCon.FolderManager.GetFoldersByIds({PartFile.FolderId}).First.Value
'_inventorApplication.Documents.Open(Folderpath & File)
End If
End If
End Sub
End Module
All the examples already have the folderpath because they use an open Inventor document or download to a temp folder.
Solved! Go to Solution.
Solved by Markus.Koechl. Go to Solution.
You can get the full file name from the results object; your code misses capturing the results.
VDF.Vault.Results.AcquireFilesResults results =
m_conn.FileManager.AcquireFiles(settings);
The results.FileResults() array lists all details. Look up "How To Acquire Files" in the SDK Help to access the code snippets context.
I hope this helps to get your final step done.
You can get the full file name from the results object; your code misses capturing the results.
VDF.Vault.Results.AcquireFilesResults results =
m_conn.FileManager.AcquireFiles(settings);
The results.FileResults() array lists all details. Look up "How To Acquire Files" in the SDK Help to access the code snippets context.
I hope this helps to get your final step done.
Thanks, using the results I can open the file:
_inventorApplication.Documents.Open(results.FileResults(0).LocalPath.ToString)
Thanks, using the results I can open the file:
_inventorApplication.Documents.Open(results.FileResults(0).LocalPath.ToString)
Can't find what you're looking for? Ask the community or share your knowledge.