Hi guys, I have a script that runs just fine from the editor, but when I put it in a button I can only RUN IT ONCE if I hit ESC.
It appears that the ESC registration is not released, so next time I run it it terminates prematurely.
Try putting this in a button:
! _NoEcho _-RunPythonScript (
import scriptcontext
import rhinoscriptsyntax as rs
n = 0
limit = 100
while True:
rs.Prompt("test "+str(n)+" of "+str(limit)+" (Press ESC to terminate)")
n += 1
rs.Sleep(100)
if n> limit:
break
if scriptcontext.escape_test(False):
print "ESC pressed"
break #get out of the loop
print "Done"
)
I am pushing a fix for this with the ScriptEditor command in Rhino 8
!_NoEcho _-ScriptEditor _Run (
#! python 3
import scriptcontext
import rhinoscriptsyntax as rs
n = 0
limit = 100
while True:
rs.Prompt("test "+str(n)+" of "+str(limit)+" (Press ESC to terminate)")
n += 1
rs.Sleep(100)
if n> limit:
break
if scriptcontext.escape_test(False):
print("ESC pressed")
break #get out of the loop
print("Done")
)