01-05-2021
05:27 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
01-05-2021
05:27 AM
Executing a controldefinition will give the same result as clicking the button in the UI manually. Therefore, the check in command will be run on the document that is active at the time when you execute the command.
I think you'll get your desired result if you make sure to activate each drawing document before executing the command (oDoc.Activate). Otherwise it's like a lottery which document will be checked in (The one that gets activated when the previously active document is closed)
Try this ![]()
Sub CheckInMultipleOpenDrawings()
Dim oDoc As Inventor.Document
For Each oDoc In ThisApplication.Documents.VisibleDocuments
If oDoc.DocumentType <> kDrawingDocumentObject Then
GoTo NextDoc
ElseIf oDoc.DocumentType = kDrawingDocumentObject Then
oDoc.Activate 'Activate the drawing
oDoc.Save
Set ControlDefinition = ThisApplication.CommandManager.ControlDefinitions.Item("VaultCheckinTop")
ControlDefinition.Execute2 (True)
oDoc.Close
End If
NextDoc:
Next
MsgBox "Checked-in the drawings"
End Sub
Jhoel Forshav
Download my free Inventor Addin - Hole Projector
LinkedIn | Ideas | Contributions | Blog posts | Website