You can do something like this:
You may or may not need to specify the full path of the references.
AddReference "C:\Program Files\Autodesk\Vault Client 2025\Explorer\Autodesk.Connectivity.WebServices.dll"
Imports AWS = Autodesk.Connectivity.WebServices
AddReference "C:\Program Files\Autodesk\Vault Client 2025\Explorer\Autodesk.DataManagement.Client.Framework.Vault.dll"
Imports VDFV = Autodesk.DataManagement.Client.Framework.Vault
AddReference "C:\Program Files\Autodesk\Vault Client 2025\Explorer\Autodesk.DataManagement.Client.Framework.dll"
Imports VDF = Autodesk.DataManagement.Client.Framework
AddReference "C:\Program Files\Autodesk\Vault Client 2025\Explorer\Connectivity.Application.VaultBase.dll"
Imports VB = Connectivity.Application.VaultBase
AddReference "Autodesk.Connectivity.WebServices.dll"
Imports AWS = Autodesk.Connectivity.WebServices
AddReference "Autodesk.DataManagement.Client.Framework.Vault.dll"
Imports VDFV = Autodesk.DataManagement.Client.Framework.Vault
AddReference "Autodesk.DataManagement.Client.Framework.dll"
Imports VDF = Autodesk.DataManagement.Client.Framework
AddReference "Connectivity.Application.VaultBase.dll"
Imports VB = Connectivity.Application.VaultBase
Sub Main()
Break()
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
Dim oDoc As Document = ThisApplication.ActiveEditDocument
Dim oDocMasterId As Long = GetVaultFileMasterID(oDoc.FullFileName, oVaultConnection)
Dim oAllFileVersions() As AWS.File = oVaultConnection.WebServiceManager.DocumentService.GetFilesByMasterId(oDocMasterId)
If oAllFileVersions Is Nothing OrElse oAllFileVersions.Length = 0 Then
MessageBox.Show("Could not find file in Vault")
Exit Sub
End If
Dim oLatestFile As AWS.File = oAllFileVersions.OrderByDescending(Function(f) f.VerNum).First()
Dim oRevisionNumber As String = oLatestFile.FileRev.Label
Dim oRevisionComment As Object = GetFilePropertyValue(oLatestFile.Id, "Revision_comment", oVaultConnection)
' Display results
Logger.Info("File: " & oDoc.DisplayName)
Logger.Info("Revision Number: " & oRevisionNumber)
Logger.Info("Revision Comment: " & If(oRevisionComment IsNot Nothing, oRevisionComment.ToString(), "(empty)"))
MessageBox.Show("Revision: " & oRevisionNumber & vbCrLf & _
"Comment: " & If(oRevisionComment IsNot Nothing, oRevisionComment.ToString(), "(empty)"), _
"Revision Info")
End Sub
Function GetFilePropertyValue(oFileId As Long, oDisplayName As String, oVaultConnection As VDF.Vault.Currency.Connections.Connection) As Object
Dim oPropDefs() As AWS.PropDef = oVaultConnection.WebServiceManager.PropertyService.GetPropertyDefinitionsByEntityClassId("FILE")
Dim oTargetPropDef As AWS.PropDef = Nothing
For Each oPropDef As AWS.PropDef In oPropDefs
If oPropDef.DispName = oDisplayName Then
oTargetPropDef = oPropDef
Exit For
End If
Next
If oTargetPropDef Is Nothing Then
Logger.Warn("Property '" & oDisplayName & "' not found")
Return Nothing
End If
Dim oEntIds() As Long = New Long() {oFileId}
Dim oPropDefIds() As Long = New Long() {oTargetPropDef.Id}
Dim oProperties() As AWS.PropInst = oVaultConnection.WebServiceManager.PropertyService.GetProperties("FILE", oEntIds, oPropDefIds)
If oProperties IsNot Nothing AndAlso oProperties.Length > 0 Then
Return oProperties(0).Val
End If
Return Nothing
End Function
Function GetVaultFileMasterId(oLocalPath As String, oVaultConnection As VDF.Vault.Currency.Connections.Connection) As Long
Dim oWorkingFolder As String = oVaultConnection.WorkingFoldersManager.GetWorkingFolder("$/").FullPath
Dim oVaultPath As String = oLocalPath.Replace(oWorkingFolder, "$\").Replace("\", "/")
Dim oVaultPaths() As String = New String() {oVaultPath}
Dim oFiles() As AWS.File = oVaultConnection.WebServiceManager.DocumentService.FindLatestFilesByPaths(oVaultPaths)
Return oFiles(0).MasterId
End Function
If this answered your question, click 'Accept Solution'.
If this was helpful, click 'Like'.
Tyler Warner