Preventing the Grasshopper multisave dialog from appearing on Rhino Close

I have a definition that is entirely user-facing and doesn’t require any GH manipulation whatsoever. That said, the file modifies itself on a regular basis – and therefore causes the Modified flag to be set on the file, despite not changing functionally. When users quit Rhino (or Grasshopper), the user is prompted whether to save the document. It is confusing for them, as they are not Grasshopper users and don’t know what to do.

Is there any way to prevent the dialog from appearing for this file? I have tried attaching a listener to the RhinoApp.Closing event, but I get an error because the GH_Doc gets unloaded before I can create a GH_DocumentIO on it to perform a save. I also still get the multisave window.

An idea solution would either Save the document at the right time so that the multi-save dialog doesn’t appear, or modify the Modified flag so that multisave does not appear (this does not appear possible). Either way, I don’t care whether the document is saved or not.

Any thoughts?

Thanks,
Marc

Hi Marc,

An idea is to attach an event Handler to the GhDocument.SolutionEnd Event, setting the “IsModified” flag to false. Anytime GH recomputes, it sets itself to not modified at the end of the solution.

I’ve created a draft which looks like working, let me know if this could do the job.

– Xavier

TestAutoSave.gh (3.5 KB)

1 Like

Very cool! This will definitely work. Funny, I was trying to use the Modified method, which only sets the flag but can’t turn it off. Didn’t think to modify the property directly!

Thanks,
Marc

1 Like

UPDATE: Did something change with Autosave recently? I’ve been using this FileModified flag hack for a couple years now, with success – but just today I was in “Prod” mode in my current script (meaning that all filemodified flags are reverted to unmodifed automatically), and Rhino closes as expected, with no Multisave dialog – but GH creates an Autosave entry upon closing. This would be fine, except that the next time that the script is opened, it gives the user a Recovery warning, which is very not what I want to happen.

Any thoughts?

Marc
P.S. I’m in Rhino 6 SR18
P.P.S. The script in question (and GH itself) is being launched programmatically by a Rhino command

Shouldn’t have. The GH in Rhino6 code is very rarely touched, almost all work is done on R7.

Can you upload a minimal working example that shows this?

It is possible to change autosave behaviour via settings. Did those perhaps change?

Haven’t been able to come up with a minimal example yet, only having problems with my complex definition, which leads me to believe it is a complex drug cocktail side effect. Debugging in visual studio to stamp out any exceptions that may be happening on my event listeners that are fired when Rhino closes… will report back.

Thanks,
Marc

That was it! Found a few custom internal plugins that were firing silent exceptions on close, and stamping out those exceptions prevents the Autosave from being saved. User Error!! :slight_smile:

Thanks for following up.

Cheers,
Marc

1 Like