Trying to make a cancel-able python script on mac in rhino 6.
script:
import rhinoscriptsyntax as rs
import Rhino
def TimeConsumingTask():
for i in range(10000):
# Was escape key pressed?
Rhino.RhinoApp.Wait()
rs.Sleep(1)
if (scriptcontext.escape_test(False)):
print "TimeConsumingTask cancelled."
break
print i
TimeConsumingTask()
I found these commands to try and help escape_test be detected, but no luck.
Rhino.RhinoApp.Wait()
rs.Sleep(1)
Anybody have a fix for this or should it be reported as a bug?
Cheers
This still doesn’t work, when for instance used to break out of a while loop! It doesn’t crash Rhino, but the Python script runs ad absurdum and you have to exit the application, if you want it to stop.
Is there a workaround for this?
I attempted this in Version 7 (7.3.21026.13002, 2021-01-26).
Hi,
The fix is in v 7.5 RC.
I will ask the developer who fixed it if it can be back ported to 6.x although 6.x updates happen a lot less frequently than 7.x updates.
Nice! Is the Cancel button, as well as esc now supported on macOS to break out of running Python scripts?
I’ve already installed the 7.5 release candidate, but it would be nice to offer this to users of version 6, too, since it seems like such an elementary functionality.