Hello,
I am creating a tool in VB.NET to open IDWs from a list of part numbers. The most recent file gets downloaded from the vault, and then opened in Inventor. I am concerned users will override local file edits when downloading files from the vault. How do I get the file status that correlates to the icons next to each file in the Vault client?
Autodesk Vault Icon Reference | Vault Products | Autodesk Knowledge Network
Looking through the object browser, I see Autodesk.DataManagement.Client.Framework.Vault.Currency.Properties.EntityStatus.LocalEditsStateEnum, which has the members:
DoesNotHaveLocalEdits
HasLocalEdits
I am not sure how to get the EntityStatus for a vault file. I suspect it involves one of the following objects:
file | Autodesk.Connectivity.WebServices.File
connection | Autodesk.DataManagement.Client.Framework.Vault.Currency.Connections.Connection
oFileIteration | Autodesk.DataManagement.Client.Framework.Vault.Currency.Entities.FileIteration
The local edits status along with the checked in/checked out status could allow me to only download the files that do not exist locally, or where the local file is out of date. Below is my VB.NET class so far.
Imports Inventor
Imports Microsoft.Office.Interop.Excel
Imports Autodesk.DataManagement.Client.Framework.Vault
Imports Autodesk.Connectivity.WebServicesTools
Imports VDF = Autodesk.DataManagement.Client.Framework
Imports ACW = Autodesk.Connectivity.WebServices
Imports System.Collections
Imports System.Linq
Imports System.Windows.Forms
Public Class clsVault
Dim FileIters As System.Collections.Generic.ICollection(Of VDF.Vault.Currency.Entities.FileIteration)
Public Sub GetFilesFromList(parts() As String, batchSize As Long)
Form_SelectDrawings.Hide()
Form_Progress.Label_RunStatus.Text = "Getting files from vault."
Form_Progress.btnNextBatch.Enabled = False
Form_Progress.btnNextBatch.Visible = False
Form_Progress.Label_Batch.Text = ""
Form_Progress.Show()
'LOG IN
Dim results1 As Results.LogInResult = VDF.Vault.Library.ConnectionManager.LogIn("", "", "", "", VDF.Vault.Currency.Connections.AuthenticationFlags.Standard, Nothing)
If Not results1.Success Then
MsgBox("Failed to log in to vault")
results1 = Nothing
Exit Sub
End If
Dim connection As VDF.Vault.Currency.Connections.Connection = Nothing
connection = results1.Connection
'GET INVENTOR
Dim m_inventorApp As Inventor.Application = Nothing
Try
m_inventorApp = System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application")
Catch ex As Exception
'MsgBox("Could not reference open Inventor. Launch Inventor and try again.")
End Try
Try
If m_inventorApp Is Nothing Then
MsgBox("Could not reference open Inventor. Launch Inventor and try again.")
connection = Nothing
End
Return
End If
Catch
End Try
Dim filePropDefs As ACW.PropDef() =
connection.WebServiceManager.PropertyService.GetPropertyDefinitionsByEntityClassId("FILE")
Dim fileNamePropDef As ACW.PropDef =
filePropDefs.[Single](Function(n) n.SysName = "ClientFileName")
Dim filepaths As New List(Of String)()
Dim files As New List(Of ACW.File)()
Dim part As String = vbNullString
For Each part In parts
If part IsNot Nothing Then
' SrchOper 1 => contains
' SrchOper 3 => equals
Dim fileNameToFind As New ACW.SrchCond() With {
.PropDefId = fileNamePropDef.Id,
.PropTyp = ACW.PropertySearchType.SingleProperty,
.SrchOper = 1,
.SrchRule = ACW.SearchRuleType.Must,
.SrchTxt = part '"C0011A05P008 Guard Rear Bracket"
}
Dim bookmark As String = String.Empty
Dim status As ACW.SrchStatus = Nothing
Dim totalResults As New List(Of ACW.File)()
Dim rslt As ACW.File
While status Is Nothing OrElse totalResults.Count < status.TotalHits
Dim results As ACW.File() =
connection.WebServiceManager.DocumentService.FindFilesBySearchConditions(New ACW.SrchCond() {fileNameToFind}, Nothing, Nothing, False, True, bookmark, status)
If results IsNot Nothing Then
'File(s) found
totalResults.AddRange(results)
For Each rslt In totalResults
If Microsoft.VisualBasic.Right(rslt.Name, 4) = ".idw" Then
'Add to list of file paths
files.Add(rslt)
Dim results2 As ACW.FilePath() = connection.WebServiceManager.DocumentService.FindFilePathsByNameAndChecksum(rslt.Name, rslt.Cksum)
If results2 IsNot Nothing Then
filepaths.Add(results2(0).Path)
End If
End If
Next rslt
Else
Exit While
End If
End While
' total results now has the results
End If
Next part
Dim DocService As ACW.DocumentService
DocService = connection.WebServiceManager.DocumentService
Dim file As ACW.File
'get settings
Dim oSettings As VDF.Vault.Settings.AcquireFilesSettings = New VDF.Vault.Settings.AcquireFilesSettings(connection)
oSettings.DefaultAcquisitionOption = VDF.Vault.Settings.AcquireFilesSettings.AcquisitionOption.Download 'Or VDF.Vault.Settings.AcquireFilesSettings.AcquisitionOption.Checkout
For Each file In files
Dim oFileIteration As VDF.Vault.Currency.Entities.FileIteration = Nothing
oFileIteration = New VDF.Vault.Currency.Entities.FileIteration(connection, file)
Try
If oFileIteration IsNot Nothing Then
oSettings.AddEntityToAcquire(oFileIteration)
Form_Progress.ListBox_Files.Items.Insert(0, "Download requested " & file.Name)
End If
Catch ex As Exception
Return
Finally
End Try
Next
Try
connection.FileManager.AcquireFiles(oSettings)
Form_Progress.ListBox_Files.Items.Insert(0, "Downloading files from vault")
Catch ex As Exception
Return
End Try
VDF.Vault.Library.ConnectionManager.LogOut(connection)
Dim filepath As String = vbNullString
Dim numFiles As Long = filepaths.Count
Dim numFile As Long = 0
Dim batches As Long = -Int(-numFiles / batchSize)
Dim batch As Long = 0
Form_Progress.Label_RunStatus.Text = "Opening drawings"
For Each filepath In filepaths
If numFile Mod batchSize = 0 Then
batch += 1
Form_Progress.Label_Batch.Text = "Batch " & batch.ToString & " of " & batches.ToString
If numFile > 0 Then
'Show modal form
Form_Progress.Label_RunStatus.Text = "PAUSED"
Form_Progress.btnNextBatch.Enabled = True
Form_Progress.btnNextBatch.Visible = True
Form_Progress.btnNextBatch.Select()
Form_Progress.Visible = False
If Form_Progress.ShowDialog() = DialogResult.OK Then
' Form was closed via OK button or similar, continue normally... '
Else
' Form was aborted via Cancel, Close, or some other way; do something '
' else like quitting the application... '
m_inventorApp = Nothing
myString = Nothing
results1 = Nothing
connection = Nothing
filePropDefs = Nothing
fileNamePropDef = Nothing
filepaths = Nothing
files = Nothing
DocService = Nothing
file = Nothing
oSettings = Nothing
MsgBox("Abort")
End
End If
Form_Progress.btnNextBatch.Enabled = False
Form_Progress.btnNextBatch.Visible = False
Form_Progress.Label_RunStatus.Text = "Opening drawings"
Form_Progress.Show()
End If
End If
filepath = filepath.Replace("$/", "C:\Vault_Workspace\ABTEX_Vault\")
filepath = filepath.Replace("/", "\")
m_inventorApp.Documents.Open(filepath)
Form_Progress.ListBox_Files.Items.Insert(0, "Opened " & filepath)
numFile += 1 'increment
Next
m_inventorApp = Nothing
myString = Nothing
results1 = Nothing
connection = Nothing
filePropDefs = Nothing
fileNamePropDef = Nothing
filepaths = Nothing
files = Nothing
DocService = Nothing
file = Nothing
oSettings = Nothing
End Sub
End Class
Any help with this would be greatly appreciated.
Kind regards,
Rafael
INV2022.3 Professional
WIN10PRO x64
Visual Studio 2019
Hello,
I am creating a tool in VB.NET to open IDWs from a list of part numbers. The most recent file gets downloaded from the vault, and then opened in Inventor. I am concerned users will override local file edits when downloading files from the vault. How do I get the file status that correlates to the icons next to each file in the Vault client?
Autodesk Vault Icon Reference | Vault Products | Autodesk Knowledge Network
Looking through the object browser, I see Autodesk.DataManagement.Client.Framework.Vault.Currency.Properties.EntityStatus.LocalEditsStateEnum, which has the members:
DoesNotHaveLocalEdits
HasLocalEdits
I am not sure how to get the EntityStatus for a vault file. I suspect it involves one of the following objects:
file | Autodesk.Connectivity.WebServices.File
connection | Autodesk.DataManagement.Client.Framework.Vault.Currency.Connections.Connection
oFileIteration | Autodesk.DataManagement.Client.Framework.Vault.Currency.Entities.FileIteration
The local edits status along with the checked in/checked out status could allow me to only download the files that do not exist locally, or where the local file is out of date. Below is my VB.NET class so far.
Imports Inventor
Imports Microsoft.Office.Interop.Excel
Imports Autodesk.DataManagement.Client.Framework.Vault
Imports Autodesk.Connectivity.WebServicesTools
Imports VDF = Autodesk.DataManagement.Client.Framework
Imports ACW = Autodesk.Connectivity.WebServices
Imports System.Collections
Imports System.Linq
Imports System.Windows.Forms
Public Class clsVault
Dim FileIters As System.Collections.Generic.ICollection(Of VDF.Vault.Currency.Entities.FileIteration)
Public Sub GetFilesFromList(parts() As String, batchSize As Long)
Form_SelectDrawings.Hide()
Form_Progress.Label_RunStatus.Text = "Getting files from vault."
Form_Progress.btnNextBatch.Enabled = False
Form_Progress.btnNextBatch.Visible = False
Form_Progress.Label_Batch.Text = ""
Form_Progress.Show()
'LOG IN
Dim results1 As Results.LogInResult = VDF.Vault.Library.ConnectionManager.LogIn("", "", "", "", VDF.Vault.Currency.Connections.AuthenticationFlags.Standard, Nothing)
If Not results1.Success Then
MsgBox("Failed to log in to vault")
results1 = Nothing
Exit Sub
End If
Dim connection As VDF.Vault.Currency.Connections.Connection = Nothing
connection = results1.Connection
'GET INVENTOR
Dim m_inventorApp As Inventor.Application = Nothing
Try
m_inventorApp = System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application")
Catch ex As Exception
'MsgBox("Could not reference open Inventor. Launch Inventor and try again.")
End Try
Try
If m_inventorApp Is Nothing Then
MsgBox("Could not reference open Inventor. Launch Inventor and try again.")
connection = Nothing
End
Return
End If
Catch
End Try
Dim filePropDefs As ACW.PropDef() =
connection.WebServiceManager.PropertyService.GetPropertyDefinitionsByEntityClassId("FILE")
Dim fileNamePropDef As ACW.PropDef =
filePropDefs.[Single](Function(n) n.SysName = "ClientFileName")
Dim filepaths As New List(Of String)()
Dim files As New List(Of ACW.File)()
Dim part As String = vbNullString
For Each part In parts
If part IsNot Nothing Then
' SrchOper 1 => contains
' SrchOper 3 => equals
Dim fileNameToFind As New ACW.SrchCond() With {
.PropDefId = fileNamePropDef.Id,
.PropTyp = ACW.PropertySearchType.SingleProperty,
.SrchOper = 1,
.SrchRule = ACW.SearchRuleType.Must,
.SrchTxt = part '"C0011A05P008 Guard Rear Bracket"
}
Dim bookmark As String = String.Empty
Dim status As ACW.SrchStatus = Nothing
Dim totalResults As New List(Of ACW.File)()
Dim rslt As ACW.File
While status Is Nothing OrElse totalResults.Count < status.TotalHits
Dim results As ACW.File() =
connection.WebServiceManager.DocumentService.FindFilesBySearchConditions(New ACW.SrchCond() {fileNameToFind}, Nothing, Nothing, False, True, bookmark, status)
If results IsNot Nothing Then
'File(s) found
totalResults.AddRange(results)
For Each rslt In totalResults
If Microsoft.VisualBasic.Right(rslt.Name, 4) = ".idw" Then
'Add to list of file paths
files.Add(rslt)
Dim results2 As ACW.FilePath() = connection.WebServiceManager.DocumentService.FindFilePathsByNameAndChecksum(rslt.Name, rslt.Cksum)
If results2 IsNot Nothing Then
filepaths.Add(results2(0).Path)
End If
End If
Next rslt
Else
Exit While
End If
End While
' total results now has the results
End If
Next part
Dim DocService As ACW.DocumentService
DocService = connection.WebServiceManager.DocumentService
Dim file As ACW.File
'get settings
Dim oSettings As VDF.Vault.Settings.AcquireFilesSettings = New VDF.Vault.Settings.AcquireFilesSettings(connection)
oSettings.DefaultAcquisitionOption = VDF.Vault.Settings.AcquireFilesSettings.AcquisitionOption.Download 'Or VDF.Vault.Settings.AcquireFilesSettings.AcquisitionOption.Checkout
For Each file In files
Dim oFileIteration As VDF.Vault.Currency.Entities.FileIteration = Nothing
oFileIteration = New VDF.Vault.Currency.Entities.FileIteration(connection, file)
Try
If oFileIteration IsNot Nothing Then
oSettings.AddEntityToAcquire(oFileIteration)
Form_Progress.ListBox_Files.Items.Insert(0, "Download requested " & file.Name)
End If
Catch ex As Exception
Return
Finally
End Try
Next
Try
connection.FileManager.AcquireFiles(oSettings)
Form_Progress.ListBox_Files.Items.Insert(0, "Downloading files from vault")
Catch ex As Exception
Return
End Try
VDF.Vault.Library.ConnectionManager.LogOut(connection)
Dim filepath As String = vbNullString
Dim numFiles As Long = filepaths.Count
Dim numFile As Long = 0
Dim batches As Long = -Int(-numFiles / batchSize)
Dim batch As Long = 0
Form_Progress.Label_RunStatus.Text = "Opening drawings"
For Each filepath In filepaths
If numFile Mod batchSize = 0 Then
batch += 1
Form_Progress.Label_Batch.Text = "Batch " & batch.ToString & " of " & batches.ToString
If numFile > 0 Then
'Show modal form
Form_Progress.Label_RunStatus.Text = "PAUSED"
Form_Progress.btnNextBatch.Enabled = True
Form_Progress.btnNextBatch.Visible = True
Form_Progress.btnNextBatch.Select()
Form_Progress.Visible = False
If Form_Progress.ShowDialog() = DialogResult.OK Then
' Form was closed via OK button or similar, continue normally... '
Else
' Form was aborted via Cancel, Close, or some other way; do something '
' else like quitting the application... '
m_inventorApp = Nothing
myString = Nothing
results1 = Nothing
connection = Nothing
filePropDefs = Nothing
fileNamePropDef = Nothing
filepaths = Nothing
files = Nothing
DocService = Nothing
file = Nothing
oSettings = Nothing
MsgBox("Abort")
End
End If
Form_Progress.btnNextBatch.Enabled = False
Form_Progress.btnNextBatch.Visible = False
Form_Progress.Label_RunStatus.Text = "Opening drawings"
Form_Progress.Show()
End If
End If
filepath = filepath.Replace("$/", "C:\Vault_Workspace\ABTEX_Vault\")
filepath = filepath.Replace("/", "\")
m_inventorApp.Documents.Open(filepath)
Form_Progress.ListBox_Files.Items.Insert(0, "Opened " & filepath)
numFile += 1 'increment
Next
m_inventorApp = Nothing
myString = Nothing
results1 = Nothing
connection = Nothing
filePropDefs = Nothing
fileNamePropDef = Nothing
filepaths = Nothing
files = Nothing
DocService = Nothing
file = Nothing
oSettings = Nothing
End Sub
End Class
Any help with this would be greatly appreciated.
Kind regards,
Rafael
INV2022.3 Professional
WIN10PRO x64
Visual Studio 2019
I wonder if it wouldn't be another option to download files to a temporary location for this purpose. Or to leverage the viewing file formats DWF(x) or PDF that Vault creates out of the box.
Anyway - you might have valid reasons to open the native IDW files. You can get the status information using the EntityStatusInfoImage; review a full code sample here: https://github.com/koechlm/iLogic-Vault/blob/2023/iLogic-Vault-QuickstartLibrary/iLogic-Vault%20Quic...
I hope this helps.
I wonder if it wouldn't be another option to download files to a temporary location for this purpose. Or to leverage the viewing file formats DWF(x) or PDF that Vault creates out of the box.
Anyway - you might have valid reasons to open the native IDW files. You can get the status information using the EntityStatusInfoImage; review a full code sample here: https://github.com/koechlm/iLogic-Vault/blob/2023/iLogic-Vault-QuickstartLibrary/iLogic-Vault%20Quic...
I hope this helps.
Thank you for the reply. I will work on converting snippets into my application. This looks promising.
Kind regards,
Thank you for the reply. I will work on converting snippets into my application. This looks promising.
Kind regards,
Could I please get the .sln for this project, or list of references? It looks like I am missing some references.
I copied your sample code into a C# project in Visual Studio 2019. This is the line from your sample that I am trying to convert to a VB.NET project. It has Application underlined red from the C# project.
using VltBase = Connectivity.Application.VaultBase; ///Application is underlined red for me
These are the dependencies I set. Maybe it is obvious which one I am missing?
This is what I have converted for the VB.NET project. 'Autodesk.Connectivity.Application.VaultBase' is underlined green.
Imports VltBase = Autodesk.Connectivity.Application.VaultBase 'This is underlined green
This is my current list of references in the VB.NET project. Do you know which one I might be missing?
Many thanks in advance.
Regards,
Could I please get the .sln for this project, or list of references? It looks like I am missing some references.
I copied your sample code into a C# project in Visual Studio 2019. This is the line from your sample that I am trying to convert to a VB.NET project. It has Application underlined red from the C# project.
using VltBase = Connectivity.Application.VaultBase; ///Application is underlined red for me
These are the dependencies I set. Maybe it is obvious which one I am missing?
This is what I have converted for the VB.NET project. 'Autodesk.Connectivity.Application.VaultBase' is underlined green.
Imports VltBase = Autodesk.Connectivity.Application.VaultBase 'This is underlined green
This is my current list of references in the VB.NET project. Do you know which one I might be missing?
Many thanks in advance.
Regards,
I think you need to add the highlighted reference to be found in the Inventor Bin folder:
I think you need to add the highlighted reference to be found in the Inventor Bin folder:
It looks like the VaultBase file is unavailable. I do not think I need this one yet for my current programs.
I am new to making programs in Visual Studio 2019. I am experiencing an issue that I do not understand. My first program I made in VS19 is a program called OpenDrawings [below]. It allows the user to point to an Excel list with part numbers, and each file is downloaded from the Vault and opened in Inventor. With all the drawings open, the user can run a macro to batch export PDFs, collect thumbnails, make lists: all useful for creating orders and BOMs.
Security reasons prevent me from doing a proper publish, so I simply copy the \debug\program.exe and place onto each user system for testing. This works well enough.
I am now working on a program to find all files in the workspace that have not been checked into the vault.
Everything is functional except the vault checking. The problem I am facing is the program fails to log into the vault. I have already restructured my code to look more like yours because I wanted to reuse the same Vault connection for each time the user presses 'Find Files'. Am I making a call incorrectly, particularly with Public Shared "connection" object or ConnectionManager.LogIn method?
Here is a snippet of Form_Unvaulted.vb where I annunciate the class objects oLoop and oVault and run their methods. Form_Unvaulted is the startup form.
Public Class Form_Unvaulted
Public Shared strWorkingFolder As String = "C:\Vault_Workspace\ABTEX_Vault"
Public Shared oLoop As New clsLoopFiles
Public Shared oVault As New clsVault
...
Private Sub Form_Unvaulted_Closing(sender As Object, e As EventArgs) Handles MyBase.Closing
oVault.LogOut()
oVault = Nothing
oLoop = Nothing
End Sub
Private Sub Btn_FindUnvaulted_Click(sender As Object, e As EventArgs) Handles Btn_FindUnvaulted.Click
Dim sPath As String = Me.TextBox_SearchFolder.Text
...
'Some checking happens here
...
'If not logged in to vault, try to log in
If oVault.LoggedIn = False Then
oVault.LogIn() 'This is where I get "Failed to log in"
Else
MsgBox("Already logged into Vault") 'Left visible for debugging
End If
'Make sure logged in to vault
If oVault.LoggedIn = True Then
Else
MsgBox("Unable to log into vault")
'Exit Sub 'This will be uncommented after debugging
End If
'Loop through files
oLoop.Run(sPath)
End Sub
...
End Class
Here is a chuck of the Class_Vault.vb code handling connection object and login/logout.
Imports Inventor
Imports Microsoft.Office.Interop.Excel
Imports Autodesk.DataManagement.Client.Framework.Vault
Imports Autodesk.Connectivity.WebServicesTools
Imports VDF = Autodesk.DataManagement.Client.Framework
Imports ACW = Autodesk.Connectivity.WebServices
Imports System.Collections
Imports System.Linq
Imports System.Windows.Forms
Public Class clsVault
Dim FileIters As System.Collections.Generic.ICollection(Of VDF.Vault.Currency.Entities.FileIteration)
...
Public Shared connection As VDF.Vault.Currency.Connections.Connection = Nothing
Public Shared fileNamePropDef As ACW.PropDef = Nothing
...
Private LoggedInValue As String = False
Public Property LoggedIn() As String
Get
Return LoggedInValue
End Get
Set(ByVal value As String)
LoggedInValue = value
End Set
End Property
Public Sub LogIn()
'LOG IN
Dim results1 As Results.LogInResult = VDF.Vault.Library.ConnectionManager.LogIn("server", "vault", "user", "pw", VDF.Vault.Currency.Connections.AuthenticationFlags.Standard, Nothing)
If Not results1.Success Then
MsgBox("Failed to log in to vault")
results1 = Nothing
Exit Sub
End If
LoggedInValue = True
connection = results1.Connection
Dim filePropDefs As ACW.PropDef() = connection.WebServiceManager.PropertyService.GetPropertyDefinitionsByEntityClassId("FILE")
fileNamePropDef = filePropDefs.[Single](Function(n) n.SysName = "ClientFileName")
filePropDefs = Nothing
End Sub
Public Sub LogOut()
If LoggedInValue = True Then
VDF.Vault.Library.ConnectionManager.LogOut(connection)
MsgBox("Vault connection closed")
End If
connection = Nothing
LoggedInValue = False
End Sub
...
End Class
Am I destroying reference links somehow when I copy the solution folder? For revision history, I tend to copy the entire solution folder and open the copied .sln file to make new changes. It looks like all the Autodesk referenced files are resident within the solution folder during the copy, and they point to the new copied folders as expected. Is this not the proper way to copy solutions?
There is another thing that could play a role in the "Failed to Log In to the vault" problem. In the post build events for the Vault SDK examples, there are the following commands. It looks like there are three files that get copied from \Autodesk Vault 2022 SDK\Bin\ and placed into the \Debug\ folder next to the EXE. Is there some sort of link or reference that is produced via the xcopy, or is this the same thing as me copying the files over using File Explorer? When I experienced problems signing into the vault from a copied .sln, adding the below post-build events seem to have done the trick.
I updated the post-build events within FindUnvaultedFiles.sln to look like below. After rebuilding successfully, I still get the "Failed to log in to vault" message.
I know this is a lot I threw out there. Any light you could shed on the "failed to log in to vault" problem for FindUnvaultedFiles would be greatly appreciated. I attached my solution folders for reference.
Many thanks, and kind regards,
Rafael
WIN10PROx64
INV2022.3
ADMS 2022.1.2
Visual Studio 2019
.NET Framework ver4.8.04084
It looks like the VaultBase file is unavailable. I do not think I need this one yet for my current programs.
I am new to making programs in Visual Studio 2019. I am experiencing an issue that I do not understand. My first program I made in VS19 is a program called OpenDrawings [below]. It allows the user to point to an Excel list with part numbers, and each file is downloaded from the Vault and opened in Inventor. With all the drawings open, the user can run a macro to batch export PDFs, collect thumbnails, make lists: all useful for creating orders and BOMs.
Security reasons prevent me from doing a proper publish, so I simply copy the \debug\program.exe and place onto each user system for testing. This works well enough.
I am now working on a program to find all files in the workspace that have not been checked into the vault.
Everything is functional except the vault checking. The problem I am facing is the program fails to log into the vault. I have already restructured my code to look more like yours because I wanted to reuse the same Vault connection for each time the user presses 'Find Files'. Am I making a call incorrectly, particularly with Public Shared "connection" object or ConnectionManager.LogIn method?
Here is a snippet of Form_Unvaulted.vb where I annunciate the class objects oLoop and oVault and run their methods. Form_Unvaulted is the startup form.
Public Class Form_Unvaulted
Public Shared strWorkingFolder As String = "C:\Vault_Workspace\ABTEX_Vault"
Public Shared oLoop As New clsLoopFiles
Public Shared oVault As New clsVault
...
Private Sub Form_Unvaulted_Closing(sender As Object, e As EventArgs) Handles MyBase.Closing
oVault.LogOut()
oVault = Nothing
oLoop = Nothing
End Sub
Private Sub Btn_FindUnvaulted_Click(sender As Object, e As EventArgs) Handles Btn_FindUnvaulted.Click
Dim sPath As String = Me.TextBox_SearchFolder.Text
...
'Some checking happens here
...
'If not logged in to vault, try to log in
If oVault.LoggedIn = False Then
oVault.LogIn() 'This is where I get "Failed to log in"
Else
MsgBox("Already logged into Vault") 'Left visible for debugging
End If
'Make sure logged in to vault
If oVault.LoggedIn = True Then
Else
MsgBox("Unable to log into vault")
'Exit Sub 'This will be uncommented after debugging
End If
'Loop through files
oLoop.Run(sPath)
End Sub
...
End Class
Here is a chuck of the Class_Vault.vb code handling connection object and login/logout.
Imports Inventor
Imports Microsoft.Office.Interop.Excel
Imports Autodesk.DataManagement.Client.Framework.Vault
Imports Autodesk.Connectivity.WebServicesTools
Imports VDF = Autodesk.DataManagement.Client.Framework
Imports ACW = Autodesk.Connectivity.WebServices
Imports System.Collections
Imports System.Linq
Imports System.Windows.Forms
Public Class clsVault
Dim FileIters As System.Collections.Generic.ICollection(Of VDF.Vault.Currency.Entities.FileIteration)
...
Public Shared connection As VDF.Vault.Currency.Connections.Connection = Nothing
Public Shared fileNamePropDef As ACW.PropDef = Nothing
...
Private LoggedInValue As String = False
Public Property LoggedIn() As String
Get
Return LoggedInValue
End Get
Set(ByVal value As String)
LoggedInValue = value
End Set
End Property
Public Sub LogIn()
'LOG IN
Dim results1 As Results.LogInResult = VDF.Vault.Library.ConnectionManager.LogIn("server", "vault", "user", "pw", VDF.Vault.Currency.Connections.AuthenticationFlags.Standard, Nothing)
If Not results1.Success Then
MsgBox("Failed to log in to vault")
results1 = Nothing
Exit Sub
End If
LoggedInValue = True
connection = results1.Connection
Dim filePropDefs As ACW.PropDef() = connection.WebServiceManager.PropertyService.GetPropertyDefinitionsByEntityClassId("FILE")
fileNamePropDef = filePropDefs.[Single](Function(n) n.SysName = "ClientFileName")
filePropDefs = Nothing
End Sub
Public Sub LogOut()
If LoggedInValue = True Then
VDF.Vault.Library.ConnectionManager.LogOut(connection)
MsgBox("Vault connection closed")
End If
connection = Nothing
LoggedInValue = False
End Sub
...
End Class
Am I destroying reference links somehow when I copy the solution folder? For revision history, I tend to copy the entire solution folder and open the copied .sln file to make new changes. It looks like all the Autodesk referenced files are resident within the solution folder during the copy, and they point to the new copied folders as expected. Is this not the proper way to copy solutions?
There is another thing that could play a role in the "Failed to Log In to the vault" problem. In the post build events for the Vault SDK examples, there are the following commands. It looks like there are three files that get copied from \Autodesk Vault 2022 SDK\Bin\ and placed into the \Debug\ folder next to the EXE. Is there some sort of link or reference that is produced via the xcopy, or is this the same thing as me copying the files over using File Explorer? When I experienced problems signing into the vault from a copied .sln, adding the below post-build events seem to have done the trick.
I updated the post-build events within FindUnvaultedFiles.sln to look like below. After rebuilding successfully, I still get the "Failed to log in to vault" message.
I know this is a lot I threw out there. Any light you could shed on the "failed to log in to vault" problem for FindUnvaultedFiles would be greatly appreciated. I attached my solution folders for reference.
Many thanks, and kind regards,
Rafael
WIN10PROx64
INV2022.3
ADMS 2022.1.2
Visual Studio 2019
.NET Framework ver4.8.04084
Hi Rafael, I am sorry - I misunderstood: my shared sample code works in the context of Inventor and re-uses the existing connection. To achieve this, the Connectivity.Application.VaultBase.dll is required. It is not relevant to your standalone application. Your application needs to establish an individual connection and cannot re-use the login of a Vault application like Inventor or Vault Explorer.
Please understand that I can't investigate in detail your project/solution. Instead, you should compare your preferences, settings, and login approach with the SDK sample solution "VaultBrowserSample". It is a standalone application like yours.
Hi Rafael, I am sorry - I misunderstood: my shared sample code works in the context of Inventor and re-uses the existing connection. To achieve this, the Connectivity.Application.VaultBase.dll is required. It is not relevant to your standalone application. Your application needs to establish an individual connection and cannot re-use the login of a Vault application like Inventor or Vault Explorer.
Please understand that I can't investigate in detail your project/solution. Instead, you should compare your preferences, settings, and login approach with the SDK sample solution "VaultBrowserSample". It is a standalone application like yours.
Thank you for the guidance.
Might I ask how you are implementing your code in the context of Inventor? I am familiar with Visual Basic for Applications in the context of Excel and Inventor. This is where the bulk of my macros reside. It is definitely my preference to use VBA for the Vault functions, but this is not possible to my understanding.
Are you using a similar API, but using VB.NET/C# instead? Is your code meant to run as an Add-In or Plug-in for Inventor? Is this code meant to exist in an iLogic Rule?
Kind regards,
Thank you for the guidance.
Might I ask how you are implementing your code in the context of Inventor? I am familiar with Visual Basic for Applications in the context of Excel and Inventor. This is where the bulk of my macros reside. It is definitely my preference to use VBA for the Vault functions, but this is not possible to my understanding.
Are you using a similar API, but using VB.NET/C# instead? Is your code meant to run as an Add-In or Plug-in for Inventor? Is this code meant to exist in an iLogic Rule?
Kind regards,
Hi thank you very much for this app!
Is it possible to add a setting to set manualy a WorkSpace path ?
Because i have this message : " Selected Folder is outside of the active workspace "
Thank you very much,
Regards,
Hi thank you very much for this app!
Is it possible to add a setting to set manualy a WorkSpace path ?
Because i have this message : " Selected Folder is outside of the active workspace "
Thank you very much,
Regards,
You can do this by forking your branch of the published source code. I will not add new features to this library; Inventor 2024 started including this as a default. You could submit an Inventor Idea to discuss your request; the information given so far, I would not vote to add this option because the scope of iLogic is Inventor, which requires files within the active workspace. If you create export files targeting other locations, I suggest downloading them to the workspace first and moving them as needed.
You can do this by forking your branch of the published source code. I will not add new features to this library; Inventor 2024 started including this as a default. You could submit an Inventor Idea to discuss your request; the information given so far, I would not vote to add this option because the scope of iLogic is Inventor, which requires files within the active workspace. If you create export files targeting other locations, I suggest downloading them to the workspace first and moving them as needed.
@rcolon9E4ZX
did you find your solution?
@rcolon9E4ZX
did you find your solution?
Thank you for checking. I did not get an answer for the vault status icon.
@Markus.Koechl posted a great chunk of code. I was able to reference it and answer some other questions I had with my project. But I don't believe it referenced explicitly the green dot, red dot, etc cases for the vault status icon. I could be wrong as it was many months since I reviewed his code. Part of my struggle was getting all the references mapped so I could run the program. I am also less familiar with C#.
@Markus.Koechl , it would help if you have a .sln file for posted code, as it would show the referenced files. Or better yet if you have anything similar in VB.NET.
Regards,
Thank you for checking. I did not get an answer for the vault status icon.
@Markus.Koechl posted a great chunk of code. I was able to reference it and answer some other questions I had with my project. But I don't believe it referenced explicitly the green dot, red dot, etc cases for the vault status icon. I could be wrong as it was many months since I reviewed his code. Part of my struggle was getting all the references mapped so I could run the program. I am also less familiar with C#.
@Markus.Koechl , it would help if you have a .sln file for posted code, as it would show the referenced files. Or better yet if you have anything similar in VB.NET.
Regards,
Hmm. My last response didn't bring the thread to the top of the forum like normal. I am responding with this message to see if it does now.
Edit: I see now I was looking in the Vault Forum and not the Vault Customization Forum. Please disregard.
Hmm. My last response didn't bring the thread to the top of the forum like normal. I am responding with this message to see if it does now.
Edit: I see now I was looking in the Vault Forum and not the Vault Customization Forum. Please disregard.
did you maybe try this code?
did you maybe try this code?
Thank you for checking. I believe the code in the link may be a subset of the same code @Markus.Koechl supplied in this thread. It is also in C#. I could not find a good source for what references to make and where the files are located, for this Vault interface using C#.
Regards,
Thank you for checking. I believe the code in the link may be a subset of the same code @Markus.Koechl supplied in this thread. It is also in C#. I could not find a good source for what references to make and where the files are located, for this Vault interface using C#.
Regards,
@rcolon9E4ZX
I found an old thread ( https://forums.autodesk.com/t5/vault-forum/property-export-to-excel-for-multiple-files/m-p/9167710#M... ) with an interesting hint. That is: if you select specifit file (part, assembly) in Vault and you go to File->Export-> xls, txt what ever, you get table with info if it is checked out, local file modified, local file wrong version...
I don't have any knowledge with VB NET, neither have prepared environment for testing this method, so I am turning to you:
could you check, if you can export, extract data and use this data for file status check?
@rcolon9E4ZX
I found an old thread ( https://forums.autodesk.com/t5/vault-forum/property-export-to-excel-for-multiple-files/m-p/9167710#M... ) with an interesting hint. That is: if you select specifit file (part, assembly) in Vault and you go to File->Export-> xls, txt what ever, you get table with info if it is checked out, local file modified, local file wrong version...
I don't have any knowledge with VB NET, neither have prepared environment for testing this method, so I am turning to you:
could you check, if you can export, extract data and use this data for file status check?
Yes. From Vault Client > File > Export, I can export the active vault view to xls.
There is a column that tells me the information I need. But this is using the GUI. I need something that the API can produce just-in-time, and for individual files.
Here is a snippet where this vault status could be applied. Before the snippet, I make a collection 'files' based on a user supplied list. This snippet then loops through the files and adds the download request.
Dim DocService As ACW.DocumentService
DocService = connection.WebServiceManager.DocumentService
Dim file As ACW.File
'get settings
Dim oSettings As VDF.Vault.Settings.AcquireFilesSettings = New VDF.Vault.Settings.AcquireFilesSettings(connection)
oSettings.DefaultAcquisitionOption = VDF.Vault.Settings.AcquireFilesSettings.AcquisitionOption.Download 'Or VDF.Vault.Settings.AcquireFilesSettings.AcquisitionOption.Checkout
For Each file In files
Dim oFileIteration As VDF.Vault.Currency.Entities.FileIteration = Nothing
oFileIteration = New VDF.Vault.Currency.Entities.FileIteration(connection, file)
Try
If oFileIteration IsNot Nothing Then
MsgBox("Adding part")
oSettings.AddEntityToAcquire(oFileIteration)
Form_Progress.ListBox_Files.Items.Insert(0, "Download requested " & file.Name)
End If
Catch ex As Exception
Return
Finally
End Try
Next
I am using this to open many drawings at once, so they can all be exported at once. The Vault status would be useful because now if a drawing is checked out, the software can flag the user that the opened drawing may be out of date. I also plan to use the Vault status when checking for unvaulted files, and detecting local edits that have not been vaulted (Write-Enabled at save).
This would be really useful. Maybe someone knows how to get the Vault status (green dot, red dot) of a file, in the context of the below, perhaps?
Autodesk.Connectivity.WebServices.File Autodesk.DataManagement.Client.Framework..Vault.Currency.Entities.FileIteration
Regards,
Yes. From Vault Client > File > Export, I can export the active vault view to xls.
There is a column that tells me the information I need. But this is using the GUI. I need something that the API can produce just-in-time, and for individual files.
Here is a snippet where this vault status could be applied. Before the snippet, I make a collection 'files' based on a user supplied list. This snippet then loops through the files and adds the download request.
Dim DocService As ACW.DocumentService
DocService = connection.WebServiceManager.DocumentService
Dim file As ACW.File
'get settings
Dim oSettings As VDF.Vault.Settings.AcquireFilesSettings = New VDF.Vault.Settings.AcquireFilesSettings(connection)
oSettings.DefaultAcquisitionOption = VDF.Vault.Settings.AcquireFilesSettings.AcquisitionOption.Download 'Or VDF.Vault.Settings.AcquireFilesSettings.AcquisitionOption.Checkout
For Each file In files
Dim oFileIteration As VDF.Vault.Currency.Entities.FileIteration = Nothing
oFileIteration = New VDF.Vault.Currency.Entities.FileIteration(connection, file)
Try
If oFileIteration IsNot Nothing Then
MsgBox("Adding part")
oSettings.AddEntityToAcquire(oFileIteration)
Form_Progress.ListBox_Files.Items.Insert(0, "Download requested " & file.Name)
End If
Catch ex As Exception
Return
Finally
End Try
Next
I am using this to open many drawings at once, so they can all be exported at once. The Vault status would be useful because now if a drawing is checked out, the software can flag the user that the opened drawing may be out of date. I also plan to use the Vault status when checking for unvaulted files, and detecting local edits that have not been vaulted (Write-Enabled at save).
This would be really useful. Maybe someone knows how to get the Vault status (green dot, red dot) of a file, in the context of the below, perhaps?
Autodesk.Connectivity.WebServices.File Autodesk.DataManagement.Client.Framework..Vault.Currency.Entities.FileIteration
Regards,
I would not recommend any path other than directly querying the file status as Vault internally does to display the Icons. The code to get the file status and all its variants is this: iLogic-Vault/iLogic-Vault-QuickstartLibrary/iLogic-Vault QuickstartLibrary.cs at 2023 · koechlm/iLog.... You need to evaluate each property of the result to get all the information and combine it. The evaluation starts in this line: iLogic-Vault/iLogic-Vault-QuickstartLibrary/iLogic-Vault QuickstartLibrary.cs at 2023 · koechlm/iLog.... You can check the possible values for each in the SDK documentation like this:
The White, Green, CheckMark, etc., icons are the result of multiple details returned by the EntityStatus. The details provide much more information than the icon could do.
Unfortunately, I don't have the same in VB.NET but a code converter returns this for the section that I referenced:
Private Sub SurroundingSub()
Dim mFileIteration As VDF.Vault.Currency.Entities.FileIteration = New VDF.Vault.Currency.Entities.FileIteration(conn, mFile)
Dim mProps As PropertyDefinitionDictionary = conn.PropertyManager.GetPropertyDefinitions(VDF.Vault.Currency.Entities.EntityClassIds.Files, Nothing, PropertyDefinitionFilter.IncludeAll)
Dim mVaultStatus As PropertyDefinition = mProps(PropertyDefinitionIds.Client.VaultStatus)
Dim status As EntityStatusImageInfo = TryCast(conn.PropertyManager.GetPropertyValue(mFileIteration, mVaultStatus, Nothing), EntityStatusImageInfo)
keyValues.Add("CheckOutState", status.Status.CheckoutState.ToString())
keyValues.Add("ConsumableState", status.Status.ConsumableState.ToString())
keyValues.Add("ErrorState", status.Status.ErrorState.ToString())
keyValues.Add("LocalEditsState", status.Status.LocalEditsState.ToString())
keyValues.Add("LockState", status.Status.LockState.ToString())
keyValues.Add("RevisionState", status.Status.RevisionState.ToString())
keyValues.Add("VersionState", status.Status.VersionState.ToString())
Return keyValues
End Sub
I would not recommend any path other than directly querying the file status as Vault internally does to display the Icons. The code to get the file status and all its variants is this: iLogic-Vault/iLogic-Vault-QuickstartLibrary/iLogic-Vault QuickstartLibrary.cs at 2023 · koechlm/iLog.... You need to evaluate each property of the result to get all the information and combine it. The evaluation starts in this line: iLogic-Vault/iLogic-Vault-QuickstartLibrary/iLogic-Vault QuickstartLibrary.cs at 2023 · koechlm/iLog.... You can check the possible values for each in the SDK documentation like this:
The White, Green, CheckMark, etc., icons are the result of multiple details returned by the EntityStatus. The details provide much more information than the icon could do.
Unfortunately, I don't have the same in VB.NET but a code converter returns this for the section that I referenced:
Private Sub SurroundingSub()
Dim mFileIteration As VDF.Vault.Currency.Entities.FileIteration = New VDF.Vault.Currency.Entities.FileIteration(conn, mFile)
Dim mProps As PropertyDefinitionDictionary = conn.PropertyManager.GetPropertyDefinitions(VDF.Vault.Currency.Entities.EntityClassIds.Files, Nothing, PropertyDefinitionFilter.IncludeAll)
Dim mVaultStatus As PropertyDefinition = mProps(PropertyDefinitionIds.Client.VaultStatus)
Dim status As EntityStatusImageInfo = TryCast(conn.PropertyManager.GetPropertyValue(mFileIteration, mVaultStatus, Nothing), EntityStatusImageInfo)
keyValues.Add("CheckOutState", status.Status.CheckoutState.ToString())
keyValues.Add("ConsumableState", status.Status.ConsumableState.ToString())
keyValues.Add("ErrorState", status.Status.ErrorState.ToString())
keyValues.Add("LocalEditsState", status.Status.LocalEditsState.ToString())
keyValues.Add("LockState", status.Status.LockState.ToString())
keyValues.Add("RevisionState", status.Status.RevisionState.ToString())
keyValues.Add("VersionState", status.Status.VersionState.ToString())
Return keyValues
End Sub
Can't find what you're looking for? Ask the community or share your knowledge.