Inventor iLogic - Autosave tool - Checking if inventor is already running a process.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am currently creating a code that will prompt the user every few minutes to whether they want to save the document due to large project models making inventor unstable/crashing more regularly. Currently this code brings up a message box that will ask the user if they want to save (yes or no), If yes is selected then the currently open document will save. if not then the counter will restart and prompt again 15 minutes later. There are currently 2 more things I want to add but am struggling to work out how to implement them. the first is to make the message box prompt forced to the top until an option is selected. The other task I would like to implement is a check so that once it gets to 15 minutes before the message box appears the code checks to see if the inventor program is currently completing a process and only opens the message box after the process is completed. For example exporting a 20-page drawing as a DWG and when it gets to page 10 the 15 minutes are up so the save message box won't appear until all 20 pages are exported, or if a process is ongoing it will skip the code and reset the timer.
Sub Main() Dim Thread1 As New System.Threading.Thread(AddressOf AutoSave) Thread1.Start() End Sub Sub AutoSave() Dim AST As Integer = 0 While True If ThisDoc IsNot Nothing Then If AST >= 15 Then '1 minutes AST = 0 Dim SF As DialogResult = MessageBox.Show("Do you want to save?", "Autosave", MessageBoxButtons.YesNo, MessageBoxIcon.Question) If SF = vbYes And ThisDoc IsNot Nothing Then ThisDoc.Save() End If Else AST += 1 End If Else AST = 0 End If System.Threading.Thread.Sleep(60000) '1 minute = 60000 ms End While End Sub