- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am writing my own version of Inventor data standards and i'm handling the OnSaveAsDialogOnFileSaveAsDialog event to show my own form that ultimately saves the document via the API. This works fine for new files and even when a user does a save as. the issue i am having is that when a user does a save as of a file from Vault, the Vault Check in command is greyed out so the user has to close and re open the document and the command is available again. In the Vault browser window it says the file is read only but checking the file properties in window explorer it isn't.
To try to resolve i am trying to close and reopen the document in Inventor which re opens the file without error but Inventor then becomes unresponsive and crashes. Code below shows what i am trying after my form has shown in the If NewFileFrm.RequiresOpen block.
Private Sub UIEvents_OnSaveAsDialogOnFileSaveAsDialog(ByRef FileTypes() As String, SaveCopyAs As Boolean,
ParentHWND As Long, ByRef FileName As String, Context As NameValueMap,
ByRef HandlingCode As HandlingCodeEnum)
Try
Dim InventorDoc As Document = Context.Item("TopLevelDocument")
If InventorDoc.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Or
InventorDoc.DocumentType = DocumentTypeEnum.kPartDocumentObject Or
InventorDoc.DocumentType = DocumentTypeEnum.kDrawingDocumentObject Then
If LoginToVault() = False Then
MsgBox("Save cancelled, log in to Vault through Inventor and try again", MsgBoxStyle.Information, "")
HandlingCode = HandlingCodeEnum.kEventCanceled
Else
Dim NewFileFrm As New NewFileForm
NewFileFrm.InventorDoc = InventorDoc
NewFileFrm.InvApp = InvApp
NewFileFrm.SaveCopyAs = SaveCopyAs
NewFileFrm.ShowDialog()
If NewFileFrm.Cancelled Then
HandlingCode = HandlingCodeEnum.kEventCanceled
Else
HandlingCode = HandlingCodeEnum.kEventHandled
If NewFileFrm.RequiresReOpen Then
'Reopen the document when a save as has been performed to refresh it
'not doing this leaves the the Vault check in command greyed out
Dim DocumentFullFileName As String = InvApp.ActiveDocument.FullDocumentName
InventorDoc.Close(True)
InvApp.Documents.Open(DocumentFullFileName)
End If
End If
End If
Else
HandlingCode = HandlingCodeEnum.kEventNotHandled
End If
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical, "")
End Try
End Sub
I have tried rebuilding the document but that doesn't work either, any ideas?
Solved! Go to Solution.