iLogic to get Check Out status (quickly)

iLogic to get Check Out status (quickly)

Jesse_Glaze
Participant Participant
328 Views
8 Replies
Message 1 of 9

iLogic to get Check Out status (quickly)

Jesse_Glaze
Participant
Participant

I came across a forum post that does allow me to successfully determine if a file is checked in or out of vault. The issue is it is a large chunk of code that takes a moment to run. I was hoping that there is a new (fast!) way to determine if a file is checked out now that there is more vault+ilogic functionality. 

 

My goal is to run a check at the beginning of some of my automatically triggered external rules, if the file is not checked out, the rule does not run.

 

Reference post:

https://forums.autodesk.com/t5/inventor-programming-ilogic/not-run-ilogic-code-if-file-is-not-check-...

0 Likes
329 Views
8 Replies
Replies (8)
Message 2 of 9

bradeneuropeArthur
Mentor
Mentor

When you mean that the check out to yourselves it is more easy than to know if the file is checked out to anyone!

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 3 of 9

g.georgiades
Advocate
Advocate

There is an iLogicVault method that will get the full vault status of a file

https://help.autodesk.com/view/INVNTOR/2025/ENU/?guid=f71217f7-2541-fd59-c39d-6a93a5395db5

 

You can use it like this from iLogic:

Dim status As Dictionary(Of String, String)

Try
	status = iLogicVault.GetVaultFileStatus(ThisDoc.Document.File.FullFileName)
Catch ex As Exception
	'user is not logged into vault, or other vault exception
	Throw
	'return
End Try

'status is guaranteed to be populated with something
Dim ErrorState As String = status("ErrorState")

'if the file is not in vault or not yet even saved, then error state will be manually set, otherwise error state will be set by vault directly.
If status("ErrorState") = "LocalFileNotFoundVaultFileNotFound" Then
	Logger.Info("New local file not yet saved!")
	Return
End If
If status("ErrorState") = "VaultFileNotFound" Then
	Logger.Info("File not found in Vault")
	Return
End If

'if status is succesful, then it will populate with these keys

Dim CheckOutState As String = status("CheckOutState")
Dim ConsumableState As String = status("ConsumableState")
Dim LocalEditsState As String = status("LocalEditsState")
Dim LockState As String = status("LockState")
Dim RevisionState As String = status("RevisionState")
Dim VersionState As String = status("VersionState")

Logger.Info(String.Format("{0}|{1}|{2}|{3}|{4}|{5}|{6}", CheckOutState, ConsumableState, LocalEditsState, LockState, RevisionState, VersionState, ErrorState))

'the possible values are listed under the EntityStatus type in the vault SDK help file

 

 

However - its speed is going to be similar to the original code you linked to. Under the hood it makes quite a few vault server calls to get the full status of the file.

 

Since all you care about is whether the file is checked out, it is heavier that you need.

 

For just checking the file's checked out status, you can use this snippet which has less vault server calls, but is a little more complex.

 

Imports AWS = Autodesk.Connectivity.WebServices
Imports VDF = Autodesk.DataManagement.Client.Framework.Vault

AddReference "Autodesk.Connectivity.WebServices.dll"
AddReference "Autodesk.DataManagement.Client.Framework.Vault.dll"

Try
	Dim connection = iLogicVault.GetVaultConnection()
	Dim vaultPath = iLogicVault.ConvertLocalPathToVaultPath(ThisDoc.Document.FullFileName) & "/" & System.IO.Path.GetFileName(ThisDoc.Document.FullFileName)
	Dim vaultFile As AWS.File = connection.WebServiceManager.DocumentService.FindLatestFilesByPaths({vaultPath}).FirstOrDefault()
	If vaultFile Is Nothing OrElse vaultFile.Id = -1 Then
		Logger.Info("File not found in vault!")
		Return
	End If

	Dim checkedOut = vaultFile.CheckedOut
	Dim checkedOutMach = vaultFile.CkOutMach

	Logger.Info("Checked out? " & checkedOut) 'true for false for any user
	Logger.Info("Checked out by machine: " & checkedOutMach) 'the PC name, does not necessarily contain the user name

	Dim checkedOutByCurrentUser = vaultFile.CkOutUserId = connection.UserID
	Logger.Info("Checked out by user: " & checkedOutByCurrentUser) 'true or false, only matches if current user is the one with the file checked out
Catch ex As Exception
	'user is not logged into vault, or other vault exception
	Throw
	'return
End Try

 

 

 

 

 

0 Likes
Message 4 of 9

C_Haines_ENG
Collaborator
Collaborator

Are you just checking if the file is checked out to you? If so, I think you could just read the "Read-Only" attribute of the file to see if Vault has the file writeable to you. 

0 Likes
Message 5 of 9

bradeneuropeArthur
Mentor
Mentor

That is not the secure/sure way of doing that, as you possibly understand.

The best you check via the Vault API either via the counterdefinitions in the ribbon.

 

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 6 of 9

bradeneuropeArthur
Mentor
Mentor

Using this method is the easiest and the best you can use when not making it overcomplicated and keep it simple.

 

Dim oControlDef As Inventor.ControlDefinition
	oControlDef = ThisApplication.CommandManager.ControlDefinitions.Item("VaultCheckinTop") 'VaultCheckinTop, VaultCheckoutTop, and VaultUndoCheckoutTop
	If oControlDef.Enabled = False Then
		MsgBox("FILE IS NOT CHECKED OUT")
		Else
			MsgBox("FILE IS CHECKED OUT")
		End If

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

Message 7 of 9

g.georgiades
Advocate
Advocate

That method does seem simplier

 

I think you have to check both buttons though if the goal is to see if the current user is the one with the file checked out.

Its also helpful to refresh first before checking so you get up to date status.

 

Dim oControlDefRefresh As Inventor.ControlDefinition
Dim oControlDefCheckIn As Inventor.ControlDefinition
Dim oControlDefCheckOut As Inventor.ControlDefinition

oControlDefRefresh = ThisApplication.CommandManager.ControlDefinitions.Item("VaultRefresh")
'VaultCheckinTop, VaultCheckoutTop, and VaultUndoCheckoutTop
oControlDefCheckIn = ThisApplication.CommandManager.ControlDefinitions.Item("VaultCheckinTop")
oControlDefCheckOut = ThisApplication.CommandManager.ControlDefinitions.Item("VaultCheckoutTop")

oControlDefRefresh.Execute2(True)

If oControlDefCheckOut.Enabled = True Then
	MsgBox("FILE IS NOT CHECKED OUT BY ANY USER")
ElseIf oControlDefCheckIn.Enabled = True Then
	MsgBox("FILE IS CHECKED OUT BY YOU")
Else
	MsgBox("FILE IS CHECKED OUT BY ANOTHER USER")
End If

Message 8 of 9

C_Haines_ENG
Collaborator
Collaborator

I was going for speed above all else, maybe the cracks don't matter enough to warrant caring.

0 Likes
Message 9 of 9

bradeneuropeArthur
Mentor
Mentor

Save side is to use the Vault API!

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes