In 8.6.24101.5001, 2024-04-10,
this script
#! python 2
import Rhino
import scriptcontext as sc
def anotherCheck(s):
if sc.escape_test(throw_exception=False, reset=True):
print("escape_test WAS reset {} loop routine.".format(s))
else:
print("escape_test was NOT reset {} loop routine.".format(s))
print('-'*40)
anotherCheck("before")
for i in range(10000, 0, -1):
Rhino.RhinoApp.CommandPrompt = "Press Esc now ({})".format(i)
if sc.escape_test(throw_exception=False):
print("Esc was pressed.")
break
# anotherCheck("after")
outputs
----------------------------------------
escape_test was NOT reset before loop routine.
Esc was pressed.
when executed via either
Start Debugging
orStart Without Debugging
button in Rhino Python Editor (_EditPythonScript).- _RunPythonScript with the script containing
#! python 2
or neither#! python 2
or#! python3
.
However, it then outputs
----------------------------------------
escape_test WAS reset before loop routine.
Esc was pressed.
when executed via either
Run active script
button in Script Editor regardless if the script contains#! python 2
or#! python3
.- _RunPythonScript with
#! python3
in place of#! python 2
.
Additional observations:
- escape_test does not return True when the initial (new Rhino instance) execution is via RhinoCode.
- The reset is required even after first executing the script via non-RhinoCode.
- escape_test state is retained at the beginning of the next RhinoCode execution, regardless of which script is executed.