Announcements
Notice: Upload of PDF documents is currently unavailable across the Community due to an ongoing issue.

Using iLogic in Inventor to get Revision comments from previous (vault) versions

Using iLogic in Inventor to get Revision comments from previous (vault) versions

jaco011
Advocate Advocate
382 Views
3 Replies
Message 1 of 4

Using iLogic in Inventor to get Revision comments from previous (vault) versions

jaco011
Advocate
Advocate

Hi all,

I hope someone can help me with this one.

We have an custom property "Revision_comment" which we use to store the revision reason. I want to write

comments of previous revisions to my file (iam/ipt).

I found this https://forums.autodesk.com/t5/vault-customization-forum/access-to-file-history-through-ilogic/td-p/...but I am unable to change to code to get custom property values and revision number (We use the revision scheme -/A/B/C from vault).

 

Can somebody help me with that?

 

0 Likes
Accepted solutions (1)
383 Views
3 Replies
Replies (3)
Message 2 of 4

TylerWarner33
Advocate
Advocate

Which Inventor & Vault version are you using?

If this answered your question, click 'Accept Solution'.
If this was helpful, click 'Like'.

Tyler Warner

0 Likes
Message 3 of 4

TylerWarner33
Advocate
Advocate
Accepted solution

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

0 Likes
Message 4 of 4

jaco011
Advocate
Advocate

Thanks a lot that worked!

I combined it with the code below from the other  topic, to loop through all versions;

For Each fileVersion As AWS.File In allFileVersions.Reverse()
		Logger.Info("File: Name [" + fileVersion.Name + "] Version [" + fileVersion.VerNum.ToString() + "] ID [" + fileVersion.Id.ToString() + "] State [" +fileVersion.FileLfCyc.LfCycStateName + "]") 
Next