Inventor ilogic Stuck in a Save Loop
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hey all,
I have managed to program my self into a corner here. I wanted to add the file save location on the title block. Wipped up a quick ilogic code and set it to fire before save. This worked but you had to save it twice because when the rule runs before save the file hasn't been given a location on the disc or a file name. So simple fix, I set the event trigger to fire the rule after save. This works except if I close the drawing and don't accecpt the prompt to save the file my changes don't stick. So I added a save command to the rule to save the changes as it runs. The issue is now when the ilogic rule runs it fires off the save command which fires off the after save even trigger, which fires off the save command........and down the rabbit hole I go.
I tried setting the rule to file when an iproperty changes also, but my rule makes a custom iproperty so that starts the whole loop again.
Dim filelocation As String Dim Vault_Location As String Dim GETSheetName As String Dim save_state As String Try 'set save_state MessageBox.Show ("starting the try loop: " & save_state) save_state = iProperties.Value("Custom", "Save_State") 'save_state = True MessageBox.Show("end of try: "& save_state) Catch ' Assume error means not found so create it save_state = "True" iProperties.Value("Custom", "Save_State") = save_state MessageBox.Show("catching setting to True: " & save_state) End Try filelocation = ThisDoc.PathAndFileName(False) If InStr(filelocation, ":") Then MessageBox.Show("Path and filename:" & filelocation) ' ' Extract the Vault location from the combined file path and part name ' 'filelocation variable looks like this "C:/Vault/desgins/Project/..." - we want "Project/..." GetSheetName = Mid (filelocation, 3, Len(filelocation)-2) MessageBox.Show("Modified Path and filename:" & GetSheetName) iProperties.Value("Custom", "Vault_Location") = GetSheetName Else ' Couldn't find the ":", so just return the whole string GetSheetName = filelocation iProperties.Value("Custom", "Vault_Location") = GetSheetName End If MessageBox.Show("before if: " & save_state) If save_state = "True" Then 'this flag means this function needs to save the drawing again save_state = "False" iProperties.Value("Custom", "Save_State") = save_state ThisDoc.Save MessageBox.Show("IF statement:"& save_state) Else 'this function has already run, so we don't need to save again save_state = "False" iProperties.Value("Custom", "Save_State") = save_state End If