Exit a script before it completes
-
We have a script that will take quite a while to run.
What is the generally accepted way to stop the script in the middle of processing?Can I add a menu option that sets a variable? Or will sketchup run a second script while still running the first one?
I suppose I can throw a dummy sentinel (trigger) file into a location and check for the existance of the file at the end of each loop.
In this case each loop will take 10 to 20 seconds and we have 50 thousand loops.
-
are you wanting to abort the process or suspend, do something, resume?
In the loop itself you can add a timer and test for a key down...
john
-
The UI isn't given any chance of interrupting. Ruby runs in the main thread and blocks everything.
What is the purpose of the cancellation? For the user or as you as developer?
I some times add a debug-timeout where my loops will break out of the operation. Though, if it's a method call to the API you are out of luck as you have no access to interrupt it's processing. -
My client wants to be able to stop the process. I've got him copying a file named stop.txt into a folder. I check it every loop. Works great.
Advertisement