Code for automatic check-in @ close, ANYONE???

Code for automatic check-in @ close, ANYONE???

Anonymous
Not applicable
540 Views
5 Replies
Message 1 of 6

Code for automatic check-in @ close, ANYONE???

Anonymous
Not applicable
Hello, I have searched & searched only to find no answers. Maybe I'll call AUTODESK out on this one! I know that I'm not alone in this issue because I've seen posts dated back to 2004 that have all of the same concerns. Maybe they've found answers and never posted them, I don't know. But either way, I have yet to find an answer.
Here's my situation. Our company is new to using Inventor. The first job we did we ran Single-User project files. We are now running Shared-User projects. We can not run Vault yet because we do not have the IT resources or time to get it all setup. So please don't reply with "just use Vault." I am looking for some sort of code or routine that would automatically check-in a part when the user closes that part file. We have multiple people working on jobs and grabbing other peoples parts to make their own and going in & out of other peoples parts to check things. It is a pain to have to Steal Checkout all the time. With that being said, we aren't so worried about "locking" a model so that no one else can ever touch it. Honestly, we are looking for something similar to AutoCAD's read-only feature. Where a file is only Read-Only if a person is currently in it.

Does anyone have any sort of code, ideas, thoughts, insight, or anything that would help me? Maybe the answer is "NO, there's nothing out there like that." Which would just be a slap to the face to Autodesk (if you ask me). Maybe I'm just to comfortable with AutoCAD methods and need to adapt to Inventor. Either way, can someone put a little insight into this post as to how to handle this situation.

Any & all advice is greatly appreciated. Thanks in advance for any help & criticism that this may bring upon me.
-JRodriguez
0 Likes
541 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable
Hi,

here are my solution, works with VBA in Inventor and as VB6-AddIn (when you add the AddIn specific code).
It uses the Inventor events to do the things.

I've made 2 part's one with the auto check-in on document close and as a maybe usefull bonus the auto check-out on start editing a document.

Comment out the msgbox()-code, this is for testing only.

If you use my code in your company please report your experiences!

Have fun,
Guido

###### Here are the class-module "clsAddInAutoCheckIn" for automatic check-in, works with shared mode and semi-isolated mode Inventor-projects:

Option Explicit

Private WithEvents eA As ApplicationEvents

Private Sub Class_Initialize()

Set eA = ThisApplication.ApplicationEvents
MsgBox "AddInAutoCheckIn initialized"

End Sub

Private Sub Class_Terminate()

Set eA = Nothing
MsgBox "AddInAutoCheckIn terminated"

End Sub

Private Sub eA_OnCloseDocument(ByVal DocumentObject As Document, ByVal FullFileName As String, ByVal BeforeOrAfter As EventTimingEnum, ByVal Context As NameValueMap, HandlingCode As HandlingCodeEnum)

Static bState As Boolean

' HandlingCode = kEventNotHandled

If bState Then
Exit Sub
End If

If BeforeOrAfter kBefore Then
Exit Sub
End If

bState = True

On Error Resume Next
If DocumentObject.ReservedForWriteByMe Then
Call DocumentObject.RevertReservedForWriteByMe
End If
On Error GoTo 0

bState = False

End Sub

###### Here are the class-module "clsAddInAutoCheckOut" for automatic check-out on edit, works only with shared mode Inventor-projects, NOT with semi-isolated mode:

Option Explicit

Private WithEvents eA As ApplicationEvents

Private Sub Class_Initialize()

Set eA = ThisApplication.ApplicationEvents
MsgBox "AddInAutoCheckOut initialized"

End Sub

Private Sub Class_Terminate()

Set eA = Nothing
MsgBox "AddInAutoCheckOut terminated"

End Sub

Private Sub eA_OnNewEditObject(ByVal EditObject As Object, ByVal BeforeOrAfter As EventTimingEnum, ByVal Context As NameValueMap, HandlingCode As HandlingCodeEnum)

Static bState As Boolean

' HandlingCode = kEventNotHandled

If bState Then
Exit Sub
End If

If BeforeOrAfter kAfter Then
Exit Sub
End If

If EditObject.Type kDocumentObject Then
Exit Sub
End If

bState = True

On Error Resume Next
If Not EditObject.ReservedForWrite Then
EditObject.ReservedForWriteByMe = True
End If
On Error GoTo 0

bState = False

End Sub


###### Here are the module "AddInEvents" to start the event-handlers:

Option Explicit

Private oEvents1 As clsAddInAutoCheckOut
Private oEvents2 As clsAddInAutoCheckIn

Sub AutoCheckOutStart()

Set oEvents1 = New clsAddInAutoCheckOut

End Sub

Sub AutoCheckOutStop()

Set oEvents1 = Nothing

End Sub

Sub AutoCheckInStart()

Set oEvents2 = New clsAddInAutoCheckIn

End Sub

Sub AutoCheckInStop()

Set oEvents2 = Nothing

End Sub
0 Likes
Message 3 of 6

Anonymous
Not applicable
Have you tested this on Inventor native DWG files?

--
Dennis Jeffrey, Autodesk Inventor Certified Expert
Autodesk Manufacturing Implementation Certified Expert.
Instructor/Author/Sr. App Engr.
AIP 2008 SP2, AIP 2009 PcCillin AV
HP zv5000 AMD64 2GB
Geforce Go 440, Driver: .8185
XP Pro SP2, Windows XP Silver Theme
http://teknigroup.com
wrote in message news:5922225@discussion.autodesk.com...
Hi,

here are my solution, works with VBA in Inventor and as VB6-AddIn (when you
add the AddIn specific code).
It uses the Inventor events to do the things.

I've made 2 part's one with the auto check-in on document close and as a
maybe usefull bonus the auto check-out on start editing a document.

Comment out the msgbox()-code, this is for testing only.

If you use my code in your company please report your experiences!

Have fun,
Guido

###### Here are the class-module "clsAddInAutoCheckIn" for automatic
check-in, works with shared mode and semi-isolated mode Inventor-projects:

Option Explicit

Private WithEvents eA As ApplicationEvents

Private Sub Class_Initialize()

Set eA = ThisApplication.ApplicationEvents
MsgBox "AddInAutoCheckIn initialized"

End Sub

Private Sub Class_Terminate()

Set eA = Nothing
MsgBox "AddInAutoCheckIn terminated"

End Sub

Private Sub eA_OnCloseDocument(ByVal DocumentObject As Document, ByVal
FullFileName As String, ByVal BeforeOrAfter As EventTimingEnum, ByVal
Context As NameValueMap, HandlingCode As HandlingCodeEnum)

Static bState As Boolean

' HandlingCode = kEventNotHandled

If bState Then
Exit Sub
End If

If BeforeOrAfter kBefore Then
Exit Sub
End If

bState = True

On Error Resume Next
If DocumentObject.ReservedForWriteByMe Then
Call DocumentObject.RevertReservedForWriteByMe
End If
On Error GoTo 0

bState = False

End Sub

###### Here are the class-module "clsAddInAutoCheckOut" for automatic
check-out on edit, works only with shared mode Inventor-projects, NOT with
semi-isolated mode:

Option Explicit

Private WithEvents eA As ApplicationEvents

Private Sub Class_Initialize()

Set eA = ThisApplication.ApplicationEvents
MsgBox "AddInAutoCheckOut initialized"

End Sub

Private Sub Class_Terminate()

Set eA = Nothing
MsgBox "AddInAutoCheckOut terminated"

End Sub

Private Sub eA_OnNewEditObject(ByVal EditObject As Object, ByVal
BeforeOrAfter As EventTimingEnum, ByVal Context As NameValueMap,
HandlingCode As HandlingCodeEnum)

Static bState As Boolean

' HandlingCode = kEventNotHandled

If bState Then
Exit Sub
End If

If BeforeOrAfter kAfter Then
Exit Sub
End If

If EditObject.Type kDocumentObject Then
Exit Sub
End If

bState = True

On Error Resume Next
If Not EditObject.ReservedForWrite Then
EditObject.ReservedForWriteByMe = True
End If
On Error GoTo 0

bState = False

End Sub


###### Here are the module "AddInEvents" to start the event-handlers:

Option Explicit

Private oEvents1 As clsAddInAutoCheckOut
Private oEvents2 As clsAddInAutoCheckIn

Sub AutoCheckOutStart()

Set oEvents1 = New clsAddInAutoCheckOut

End Sub

Sub AutoCheckOutStop()

Set oEvents1 = Nothing

End Sub

Sub AutoCheckInStart()

Set oEvents2 = New clsAddInAutoCheckIn

End Sub

Sub AutoCheckInStop()

Set oEvents2 = Nothing

End Sub
0 Likes
Message 4 of 6

Anonymous
Not applicable
NO!

Good hint, I'll try this shortly.

Do you tested this? What's your experiences?
I need more reports from users, so I can improve my solution.

I have made an extension, that listends to the project-changed event, checks what project-type the current project are and enableds or disableds the auto-checkin/checkout. This is in alpha-testing now...

CU,
Guido
0 Likes
Message 5 of 6

Anonymous
Not applicable
Hi,

We are using your automatic check in code, it solves lot of troubles.

Does it still work well for you?

Thank you for the contribution

Thomas
0 Likes
Message 6 of 6

Anonymous
Not applicable
Also check out CBliss' Unreserve program. I think it still works with current releases. It is very handy when working with and managing Shared projects.

http://www.cbliss.com/inventor/iCode/index.htm

Pete
0 Likes