Use Vault API in ILogic to get comment of revision

Use Vault API in ILogic to get comment of revision

Matthew_Policelli
Advocate Advocate
702 Views
4 Replies
Message 1 of 5

Use Vault API in ILogic to get comment of revision

Matthew_Policelli
Advocate
Advocate

How do I do this?

Matthew_Policelli_0-1692646106746.png



I currently have the file checked out. I want my iLogic to get the "Copy of file..." comment from the current revision, but as far as I can tell, <FileIteration>.comment either fails to get anything, or it gets the comment from the placeholder revision that was created when I checked out the file.

Is there no way to get the comment? Below is my code:

Function GetVaultState(ByRef LastCheckInDate As DateTime) As VDF.Vault.Currency.Entities.FileIteration
	Dim mVltCon As VDF.Vault.Currency.Connections.Connection = VB.ConnectionManager.Instance.Connection

	If mVltCon Is Nothing Then Throw New System.Exception("Not Logged In")

	'Convert File Path to Vault Path
	Dim VaultPath As String = ThisDoc.PathAndFileName(True).Replace("C:\_VaultWork\", "$/").Replace("\", "/")

	Dim awsFiles() As AWS.File = mVltCon.WebServiceManager.DocumentService.FindLatestFilesByPaths(New String() {VaultPath })
	
	LastCheckInDate = awsFiles(0).ModDate	'pass the last modified date back to the main code
	Logger.Info(LastCheckInDate.ToString("MM/dd/yyyy"))	' now I should check that this actually gives the last modified date and not the current date when the file is checked out.

	Dim mFileIt As VDF.Vault.Currency.Entities.FileIteration = New VDF.Vault.Currency.Entities.FileIteration(mVltCon, awsFiles(0))
	Logger.Info(mFileIt.Comment)	' this gives a blank string
	Return mFileIt

End Function

  

0 Likes
Accepted solutions (1)
703 Views
4 Replies
Replies (4)
Message 2 of 5

Markus.Koechl
Autodesk
Autodesk

If a file is checked out, the comment is the latest text entered during the check-out command; see FileIteration -> comment property in SDK Help. So, you either need to grab the comment before you checkout or retrieve the file version current version-1 using GetFilesByVersions.

 


Markus Koechl

Solutions Engineer PDM, Autodesk Central Europe
0 Likes
Message 3 of 5

Matthew_Policelli
Advocate
Advocate

Sounds like get files by versions is what I want. How do I get the arguments needed for that function?

 

It's possible this changed with newer versions of Inventor/Vault, but with Inventor 2022 and Vault 2022, there is no description of the functions to know what the inputs should be.

0 Likes
Message 4 of 5

Markus.Koechl
Autodesk
Autodesk
Accepted solution

You can get the arguments for Vault API calls within iLogic Editor if you copy the XML documentation files and the referenced library. E.g., 

MarkusKoechl_0-1693230276276.png

Alternatively - and my recommendation on top of the Intellisense option - is reviewing the SDK documentation.

And yes, Inventor 2024 integrated an iLogic-Vault library, providing Vault access through iLogic Syntax rather than directly programming Vault API calls. You can get this as a tech-preview also for 2022 here: Release iLogic-Vault | iLogic-VaultInventorServer 2022.3 · koechlm/iLogic-Vault (github.com)



Markus Koechl

Solutions Engineer PDM, Autodesk Central Europe
0 Likes
Message 5 of 5

Matthew_Policelli
Advocate
Advocate

Just to update this and close it, I did end up figuring it out based off of this. Here is the code snippet I used to check if a file was recently design copied (by checking for the "Copy of file" comment)

 

	Function GetVaultState(ByRef LastCheckInDate As DateTime, ByRef DesignCopyBool As Boolean) As VDF.Vault.Currency.Entities.FileIteration
		Dim mVltCon As VDF.Vault.Currency.Connections.Connection = VB.ConnectionManager.Instance.Connection

		If mVltCon Is Nothing Then Throw New System.Exception("Not Logged In")

		'Convert File Path to Vault Path
		Dim VaultPath As String = ThisDoc.PathAndFileName(True).Replace("C:\_VaultWork\", "$/").Replace("\", "/")

		Dim awsFiles() As AWS.File = mVltCon.WebServiceManager.DocumentService.FindLatestFilesByPaths(New String() {VaultPath })

		'pass file properties needing checking back to calling sub
		With awsFiles(0)
			Try
				' get the previous version's comment
				Dim PrevComment As String = mVltCon.WebServiceManager.DocumentService.GetFileByVersion(.MasterId, .VerNum - 1).Comm
				
				' if properties were updated by copy design, check the comment from 2 versions ago instead
				If PrevComment = "Properties updated by Copy Design."	
					PrevComment = mVltCon.WebServiceManager.DocumentService.GetFileByVersion(.MasterId, .VerNum - 2).Comm
				End If
				
				' Check if the previous comment indicates the currently edited file is design copied.
				DesignCopyBool = PrevComment.StartsWith("Copy of file")
			Catch
				DesignCopyBool = False
			End Try

			LastCheckInDate = .ModDate	'last modified date will be the last time the file was modified before being checked into vault
		End With
... MORE CODE End Function