Hi guys,
I still can not figure out how to get the ESC test to work when the script is compiled or ran in a button.
I have tried to use both break and exit()
I also tried replacing “While True:” with “While run==True:” and then have the esc test alter “run=False” but then it just ignored the ESC and continued to run.
This works well if ran from the pythonscriptcomplier:
# Help: How to set this up to run propperly as a plugin
import rhinoscriptsyntax as rs
import scriptcontext
Total=100
nr=0
def ESC_test(nr,Total):
while True:
rs.Sleep(100)
rs.Prompt("Running cycle "+str(nr)+" of "+str(Total))
nr=nr+1
if nr==Total:
break
#check for esc press
if scriptcontext.escape_test(False):
print "ESC pressed "
break #get out of the loop
if __name__ == "__main__":
ESC_test(nr,Total)
Eventually, but definitely not today. I’ve started the mega-merge project and am focusing all of my effort there. From what I can tell, there is some subtle bug in which we will need to fix.
Sorry, but I don’t know when or where this will be fixed. If I knew the cause of the bug, it would probably be easy to fix. I understand this is not the answer you want, but it is the truth. I’m in the middle of a massive project that will most likely take at least the next month of my focused time to complete.
Hi Jørgen.
If the command that must not be repeated is the same command that you have just stopped by the RMB, then what about usind the DocumentUserText rhinoscriptsyntax functions ?
When you catch the mouse button event to stop the command, you can store a DocumentUserText entry (kind of a flag).
When your command starts, first it has to check if the DocumentUserText entry is set.
If it is set, then the command was run by the RMB event and the command must stop immediately and reset the DocumentUserText entry.
Otherwise it can run regularly (the command was run intentionally by the user).
Does this make any sense ?
I have not tried that, sorry … just an idea …
Cheers
@stevebaer why does sys.exit() close Rhino and not only the python process?
I am still trying to solve the esc issue with plugins since not being able to use esc to quit a script renders Python useless to some of the tasks I need to solve.
Can it be solved in Rhino common or in VB instead?
PLEASE help in finding a workaround if you still don’t have time to fix the bug.
I’ve been working on a project we call around here the ‘mega-merge’ since early December. This is the process of merging all of the changes in the source for Mac Rhino since it began with the current V6 Window code. This will let us develop on a single code stream for both platforms in the future and will hopefully allow us to release future Rhino versions on both platforms around the same time. This is a pretty big undertaking and I’m still trying to finish it up. It does look like I’m getting very close.
Rhino and python run in the same process which is why sys.exit shuts everything down. That is what it is designed to do.
Were you able to implement RMB the idea that Emilio had earlier in this thread?
Sorry, I still haven’t had time to investigate this issue. I understand that is frustrating and not the answer you are looking for, but it is the truth.
Hi Steve,
Thanks for the feedback. It’s frustrating, yet very understandable…
Yes, I got it working after a bit of tweaking, and it seems to do the job very well also in a plugin.
But the user interface isn’t great, as ESC is an established Canceler and RMB is used in Rhino to navigate the views, so it works, but is a bit counter intuitive.
Again thanks for understanding and helping out. Much appreciated.