Check In and Out with iLogic without Needing Vault

Check In and Out with iLogic without Needing Vault

lincoln3C326
Explorer Explorer
1,552 Views
2 Replies
Message 1 of 3

Check In and Out with iLogic without Needing Vault

lincoln3C326
Explorer
Explorer

A vital feature of Autodesk Vault or PDM software is the Check In/Check Out functionality. This prevents more than one user at a time making changes to a file, while still allowing others to view it. This is a vital feature for project collaboration, as it prevents conflicting copies being created. 

 

I am a part of a small company, and I am currently the only Inventor user. We use sharepoint for all of our projects, which allows conflicted copies. However, we have plans to expand soon, but my boss Isn’t ready to invest in something like Vault just yet. I have come up with an iLogic based Check In/Check Out feature which I wanted to share. I hope it’s useful for people in a similar situation and I would also love feedback and ideas for possible improvements. 

 

The program consists of four main rules which are described below: 

 

  1. Check Out Rule (CheckOut) 
    The check out rule creates a custom property called “Checked Out” (CO) into which the PC username is written. When the CO property matches the username the file is checked out and is set to editable. You can only check the document out if the CO property is blank. Otherwise, a message shows saying who currently owns the file.  
  1. Check In Rule (Checkin) 
    The check in rule allows the owner of the file to delete the value of the CO property. Then a message appears in the top left of the screen saying that the file is checked in. The document is then saved and set to read only. (The “Checked In” message is deleted when the file is checked out) 
  1. Initial Check Out Rule (initialCheckOut) 
    This rule checks out the document when it is created.  
  1. Open Document Rule (openDoc) 
    The Open Document Rule reads the CO property when the document opens. If it matches your username the document is editable. If it is owned by someone else, it is set to read only and a message box tells you who it is currently checked out by. Otherwise, the document checks itself in. 

 

Initial Setup 

To get the program up and running, the four rules need to be added as external rules in the iLogic browser. I save them in my server inventor template directory. Then under Manage>Event Triggers>All Documents, initialCheckOut is placed under New Document, and openDoc is placed under After Open Document. 

Currently this has to be done for each inventor installation. Which is admittedly a bit of a pain, so any suggestions on how to get this done in one step, or even on install would be great. 

 

Using the Functionality 

Once everything is set up it’s pretty straightforward to use, and in my experience pretty stable. You can run the Check In/Check Out rules from the iLogic browser or set up a global form. In the future I would like to integrate the macros so I could run it from the command ribbon or similar. Again, feedback and suggestions on this would be great. 

Normally, I make sure I check in before I close a document, which is just good practice. However, if you need to find a bunch of checked out files all over the place you can use the Design Assistant and search by property. This has been a bit hit and miss in my experience though. 

I will attach the code below. Please feel free to use, modify, and share improvements and feedback. 

 

Check In Rule

 

'CHECK IN RULE

WSHnet = CreateObject("WScript.Network")
UserName = WSHnet.UserName		
'MessageBox.Show(UserName)
'Creates the UserName object use for CO property

Dim oDoc As Document
oDoc = ThisApplication.ActiveDocument
oDoc.Save
oPropertySet = ThisApplication.ActiveDocument.PropertySets.Item("User Defined Properties")


Try
oPropertySet.Add("", "Checked Out")
Catch
End Try
'Checks if checked out property has been created. If not, creates the property

If oPropertySet.Item("Checked Out").Value = UserName
	
	oPropertySet.Item("Checked Out").Value = ""
		
'If the File Is checked Out By the current user, File Is checked In. i.e. checked Out Property
'Set To blank And File state Set To read only
	
Try
	Dim oPartDoc As PartDocument
	oPartDoc = ThisApplication.ActiveDocument

	Dim oCompDef As PartComponentDefinition
	oCompDef = oPartDoc.ComponentDefinition
	Try	
		oNoteD = oCompDef.ModelAnnotations.ModelGeneralNotes.Item("CheckedInNote")
		oNoteD.Delete
	Catch
	End Try
	
  	Dim oNoteDef As ModelGeneralNoteDefinition
oNoteDef = oCompDef.ModelAnnotations.ModelGeneralNotes.CreateDefinition("Checked In", True,kUpperLeftQuadrant)
  	Dim oNote As ModelGeneralNote
  	oNote = oCompDef.ModelAnnotations.ModelGeneralNotes.Add(oNoteDef)
 	oNote.Name = "CheckedInNote"

'attempts to create a Checked In Note in the part environment
'If that fails it will try and create it in the drawing environment

Catch
	Try 
	oDrawDoc = ThisApplication.ActiveDocument
	Dim oSheet As Sheet
	oSheet = oDrawDoc.ActiveSheet

	Dim oTG As TransientGeometry
	oTG = ThisApplication.TransientGeometry

	Dim oSketchSymbolDef As SketchedSymbolDefinition
	oSketchSymbolDef = oDrawDoc.SketchedSymbolDefinitions.Item("CheckedInNote")
	Dim oSketchSymbol As SketchedSymbol
	oSketchSymbol = oSheet.SketchedSymbols.Add(oSketchSymbolDef, oTG.CreatePoint2d(3, 31))

	Dim oSketchSymbolD As SketchedSymbolDefinition
	oSketchSymbolD = oDrawDoc.SketchedSymbolDefinitions.Item("CheckedInNote")

'attempts to create a Checked In Note in the drawing environment
'If that fails it will try and create it in the Assembly environment

	Catch

	Dim oAsmDoc As AssemblyDocument
	oAsmDoc = ThisApplication.ActiveDocument
	Dim oDef As AssemblyComponentDefinition
	oDef = oAsmDoc.ComponentDefinition

		Try
		Dim oNoteAD As ModelGeneralNote
		oNoteAD = oDef.ModelAnnotations.ModelGeneralNotes.Item("CheckedInNote")
		oNoteAD.Visible = 1
		Catch
		Dim oNoteADef As ModelGeneralNoteDefinition
oNoteADef = oDef.ModelAnnotations.ModelGeneralNotes.CreateDefinition("Checked In", True, kUpperLeftQuadrant)
		Dim oNoteA As ModelGeneralNote
		oNoteA = oDef.ModelAnnotations.ModelGeneralNotes.Add(oNoteADef)
		oNoteA.Name = "CheckedInNote"
		Catch
		End Try
	Catch
	End Try
Catch
End Try
 
 	oDoc.Save
 		sFileName = ThisApplication.ActiveEditDocument.fullfilename
	Dim oFile As System.IO.FileInfo 
	oFile = New System.IO.FileInfo(sFileName)
	oFile.IsReadOnly = True
	MessageBox.Show("File checked in")
	
	
Else
	If oPropertySet.Item("Checked Out").Value = ""
		
		oPropertySet.Item("Checked Out").Value = ""

		sFileName = ThisApplication.ActiveEditDocument.fullfilename
		Dim oFile As System.IO.FileInfo 
		oFile = New System.IO.FileInfo(sFileName)
		oFile.IsReadOnly = True
	Else
		Dim CheckOut As String
		CheckOut = oPropertySet.Item("Checked Out").Value
		MessageBox.Show("File is checked out by " & CheckOut)
	End If
End If

'End Of PROGRAM

 

 

Check Out Rule

 

'CHECK OUT RULE

WSHnet = CreateObject("WScript.Network")
UserName = WSHnet.UserName			
'MessageBox.Show(UserName)
'Creates UserName object for CO property

oPropertySet = ThisApplication.ActiveDocument.PropertySets.Item("User Defined Properties")

Try
oPropertySet.Add("", "Checked Out")	
'Adds CO property if not already done
Catch
End Try

If oPropertySet.Item("Checked Out").Value = UserName
	sFileName = ThisApplication.ActiveEditDocument.fullfilename
	Dim oFile As System.IO.FileInfo 
	oFile = New System.IO.FileInfo(sFileName)
	oFile.IsReadOnly = False
	MessageBox.Show("Already checked out by you")
	
	Try
'trys to delete checked in note if created in a model
		Dim oPartDoc As PartDocument 					
		oPartDoc = ThisApplication.ActiveDocument
		Dim oCompDef As PartComponentDefinition
		oCompDef = oPartDoc.ComponentDefinition
		Try
		oNoteD = oCompDef.ModelAnnotations.ModelGeneralNotes.Item("CheckedInNote")
		oNoteD.Delete
		Catch
		End Try
	Catch
'trys to delete checked in note if created in a drawing
			Dim oDrawDoc As DrawingDocument					
			oDrawDoc = ThisApplication.ActiveDocument
			Dim oSheet As Sheet
			oSheet = oDrawDoc.ActiveSheet
			Dim oSketchSymbol As SketchedSymbol
			oSketchSymbol = oSheet.SketchedSymbols.Item(1)
			oSketchSymbol.Delete
	Catch
'trys to delete checked in note if created in an Assembly
		Dim oAsmDoc As AssemblyDocument						
		oAsmDoc = ThisApplication.ActiveDocument
		Dim oDef As AssemblyComponentDefinition
		oDef = oAsmDoc.ComponentDefinition
		Dim oNoteAD As ModelGeneralNote
		oNoteAD = oDef.ModelAnnotations.ModelGeneralNotes.Item("CheckedInNote")
		oNoteAD.Visible = 0
	Catch

	End Try
'checks if file is checked out by current user, 
'if true user is told they already have the file checked out
'if for some reason the checked in note is still there
'it is deleted and the file is set to editable
Else
	If oPropertySet.Item("Checked Out").Value = ""
		Try
		oPropertySet.Item("Checked Out").Value = UserName
		Catch
		oPropertySet.Add("", "Checked Out")
		End Try
		oPropertySet.Item("Checked Out").Value = UserName
		

		sFileName = ThisApplication.ActiveEditDocument.fullfilename
		Dim oFile As System.IO.FileInfo 
		oFile = New System.IO.FileInfo(sFileName)
		oFile.IsReadOnly = False
		MessageBox.Show("File checked out")
		
'if the document was checked in, CO property is set to UserName and document becomes editable
		
	Try
'trys to delete checked in note if created in an part
		Dim oPartDoc As PartDocument					
		Dim oCompDef As PartComponentDefinition
		oCompDef = oPartDoc.ComponentDefinition
		Try
		oNoteD = oCompDef.ModelAnnotations.ModelGeneralNotes.Item("CheckedInNote")
		oNoteD.Delete
		Catch
		End Try
	Catch
		Try
'trys to delete checked in note if created in a drawing
		Dim oDrawDoc As DrawingDocument					
		oDrawDoc = ThisApplication.ActiveDocument
		Dim oSheet As Sheet
		oSheet = oDrawDoc.ActiveSheet
		Dim oSketchSymbol As SketchedSymbol
		oSketchSymbol = oSheet.SketchedSymbols.Item(1)
		oSketchSymbol.Delete

		Catch
'trys to delete checked in note if created in an Assembly
		Dim oAsmDoc As AssemblyDocument					
		oAsmDoc = ThisApplication.ActiveDocument
		Dim oDef As AssemblyComponentDefinition
		oDef = oAsmDoc.ComponentDefinition
		Dim oNoteAD As ModelGeneralNote
		oNoteAD = oDef.ModelAnnotations.ModelGeneralNotes.Item("CheckedInNote")
		oNoteAD.Visible = 0

		Catch
		End Try
	End Try

	Else
		Dim CheckOut As String
		CheckOut = oPropertySet.Item("Checked Out").Value
		MessageBox.Show("File is already checked out by " & CheckOut)
		sFileName = ThisApplication.ActiveEditDocument.fullfilename
		Dim oFile As System.IO.FileInfo 
		oFile = New System.IO.FileInfo(sFileName)
		oFile.IsReadOnly = False

'if the document was checked out by someone else, 
'document set to read only, and message saying who owns the document shows
	End If
End If

 

 

Initial Check Out Rule

 

WSHnet = CreateObject("WScript.Network")
UserName = WSHnet.UserName
'MessageBox.Show(UserName)

oPropertySet = ThisApplication.ActiveDocument.PropertySets.Item("User Defined Properties")

Try
oPropertySet.Add("", "Checked Out")
Catch
End Try

oPropertySet.Item("Checked Out").Value = UserName

 

 

Open Document Rule

 

Dim oDoc As Document
oDoc = ThisApplication.ActiveDocument

WSHnet = CreateObject("WScript.Network")
UserName = WSHnet.UserName
'MessageBox.Show(UserName)
oPropertySet = ThisApplication.ActiveDocument.PropertySets.Item("User Defined Properties")

 
	
Try
	oPropertySet.Add("", "Checked Out")
Catch
End Try

If oPropertySet.Item("Checked Out").Value = UserName
	MessageBox.Show("File is checked out by you")
Else
	If oPropertySet.Item("Checked Out").Value = ""
		Try
		Dim oPartDoc As PartDocument
		oPartDoc = ThisApplication.ActiveDocument

		Dim oCompDef As PartComponentDefinition
		oCompDef = oPartDoc.ComponentDefinition
			Try	
			oNoteD = oCompDef.ModelAnnotations.ModelGeneralNotes.Item("CheckedInNote")
				oNoteD.Delete
			Catch
			End Try
	
 		Dim oNoteDef As ModelGeneralNoteDefinition
 oNoteDef = oCompDef.ModelAnnotations.ModelGeneralNotes.CreateDefinition("Checked In", True,kUpperLeftQuadrant)
  		Dim oNote As ModelGeneralNote
  		oNote = oCompDef.ModelAnnotations.ModelGeneralNotes.Add(oNoteDef)
  		oNote.Name = "CheckedInNote"
 		Catch
	 		Try
				
			oDrawDoc = ThisApplication.ActiveDocument
			Dim oSheet As Sheet
			oSheet = oDrawDoc.ActiveSheet

			Dim oTG As TransientGeometry
			oTG = ThisApplication.TransientGeometry

			Dim oSketchSymbolDef As SketchedSymbolDefinition
			oSketchSymbolDef = oDrawDoc.SketchedSymbolDefinitions.Item("CheckedInNote")
			Dim oSketchSymbol As SketchedSymbol
			oSketchSymbol = oSheet.SketchedSymbols.Add(oSketchSymbolDef, oTG.CreatePoint2d(3, 31))

			Dim oSketchSymbolD As SketchedSymbolDefinition
			oSketchSymbolD = oDrawDoc.SketchedSymbolDefinitions.Item("CheckedInNote")
			
			Catch
			Dim oAsmDoc As AssemblyDocument
			oAsmDoc = ThisApplication.ActiveDocument
			Dim oDef As AssemblyComponentDefinition
			oDef = oAsmDoc.ComponentDefinition

				Try
				Dim oNoteAD As ModelGeneralNote
				oNoteAD = oDef.ModelAnnotations.ModelGeneralNotes.Item("CheckedInNote")
				oNoteAD.Visible = 1
				Catch
				Dim oNoteADef As ModelGeneralNoteDefinition
oNoteADef = oDef.ModelAnnotations.ModelGeneralNotes.CreateDefinition("Checked In", True, kUpperLeftQuadrant)
				Dim oNoteA As ModelGeneralNote
				oNoteA = oDef.ModelAnnotations.ModelGeneralNotes.Add(oNoteADef)
				oNoteA.Name = "CheckedInNote"
				Catch
				End Try
			Catch
			End Try
		Catch
 		End Try
		
		
			sFileName = ThisApplication.ActiveEditDocument.fullfilename
		Dim oFile As System.IO.FileInfo 
		oFile = New System.IO.FileInfo(sFileName)
		oFile.IsReadOnly = True
	Else
		Dim CheckOut As String
		CheckOut = oPropertySet.Item("Checked Out").Value
		MessageBox.Show("File is checked out by " & CheckOut)
		
		sFileName = ThisApplication.ActiveEditDocument.fullfilename
		Dim oFile As System.IO.FileInfo 
		oFile = New System.IO.FileInfo(sFileName)
		oFile.IsReadOnly = True
		
	End If
End If

 

1,553 Views
2 Replies
Replies (2)
Message 2 of 3

tetsu.kanazawa
Participant
Participant

Your idea is very interesting, here I would like to include our database in OneDrive, and I would lose the Vault.

Could you send a short video of how your rule works?

0 Likes
Message 3 of 3

CGBenner
Community Manager
Community Manager

@tetsu.kanazawa 

Hello.  This user has not returned to this forum since 2021 when this post was made.  We can try to tag them and see if they reply, but this may be a dead end.

@lincoln3C326 Are you still out there?  🙂

Did you find a post helpful? Then feel free to give likes to these posts!
Did your question get successfully answered? Then just click on the 'Accept solution' button.  Thanks and Enjoy!


Chris Benner
Community Manager

0 Likes