Community
Vault Customization
Share your knowledge, ask questions, and explore popular Vault API, Data Standard, and VBA topics related to programming, creating add-ins, or working with the Vault API.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Open file from Vault

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
laurence.roijackers
740 Views, 2 Replies

Open file from Vault

laurence.roijackers
Contributor
Contributor

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.

0 Likes

Open file from Vault

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.

Labels (3)
2 REPLIES 2
Message 2 of 3

Markus.Koechl
Autodesk
Autodesk
Accepted 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.



Markus Koechl

Solutions Engineer PDM, Autodesk Central Europe

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.



Markus Koechl

Solutions Engineer PDM, Autodesk Central Europe
Message 3 of 3

laurence.roijackers
Contributor
Contributor

Thanks, using the results I can open the file:

_inventorApplication.Documents.Open(results.FileResults(0).LocalPath.ToString)
0 Likes

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.

Post to forums  

Autodesk Design & Make Report