Hello,
At work, we use a custom toolbar with some custom scripts to do some repetitive operations automatically. Sometimes, the people at work using this toolbar click on the button for step 2, when the step 1 script has not yet finished running. This caused script 1 to crash. What is the best way to lock the toolbar while a script is running?
Regards!
Hi Etienne - is the script placed explicitly on the button as code, or does it run a script that is on disk someplace, or are you referring to a macro (of top level Rhino commands)? Can you post or sdend to tech@mcneel.com an example, to my attention? Please include a link back to this topic in your comments.
-Pascal
Hi Etienne - you can put a “!” in front of the macros - that should cancel the running script - better than a crash.
! _-RunPythonScript(etc etc)
Hm - I am not sure that works in this context.
-Pascal
This helps a bit, but the best thing would be to make the buttons completely unclickable (while a script is running).
Is it possible?
- Etienne
Hi Etienne, that is not possible but another workaround suggested by a colleague, if I understand the suggestion, might be to have your scripts add some bit of info to scriptcontext.sticky like
sc.sticky['Script_Is_Running'] = True
then each script could look for that setting and if True, stop.
if 'Script_Is_Running' in sc.sticky:
return
Now, of course this would require some checking to make sure each script sets that to False or, better, remove it completely before exiting, which may be a number of locations in a script.
sc.sticky.pop('Script_Is_Running', None)
-Pascal
Thank you, this help!
-Etienne