What if a user clicks cancel on a script dialogue?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am new to writing Fusion 360 scripts. I use Python.
According to my reading of the docs, you are supposed to do adsk.autoTerminate(False) in the script's run function when your script has a dialogue. Furthermore, you must do adsk.terminate() at the end of the command executed handler.
This all seems to work as described when the user hits "ok", but what if she hits "cancel" instead? I think there is a problem here, because the command executed handler does not get called when the user hits "cancel" (that makes sense). Therefore, when the user hits cancel, adsk.terminate() does not happen, and the script continues running indefinitely. The user can hit stop to get around this, but she shouldn't have to, and it's annoying and incomprehensible to her, because as far as she is concerned, the script IS done, because she hit the "cancel" button.
So, how am I supposed to ensure that adsk.terminate() happens when the user hits cancel? I figure that I'd need to register a cancel handler, but there isn't an event with that exact name. I see a couple of command events (out of a very long list) that kinda sorta look like what I want, but not really (specifically, deactivate and destroy).
Maybe the solution is to turn my script into an add-in? I avoided that at first, because script seemed simpler, but maybe scripts really do not fit with dialogues??