Hi Peer, if you press escape that will cancel a script that has spent more than 3 seconds running since the last time it waited for an event.
But the canceling will work by causing all MoI API function calls to return an exception. So if you have a tight loop that does not call any MoI functions like your while ( true ){} example that won't get interrupted. So don't do something like that.
> What does the Esc key actually do?
It tries to do various exiting or clearing type functions.
If a script has been running for more than 3 seconds since the last event wait Esc will cancel the script by triggering an exception for any MoI API function call.
For more normal usage, if there is a dialog window that has keyboard focus or if there is a flyout menu open then Esc will close that window.
If a dialog or flyout was not closed then the next thing it tries is if there is any selection filter active it will clear that.
Then the next thing is if there wasn't any selection filter cleared it will cancel any currently running command, by making the .waitForEvent() function return false. When a script sees .waitForEvent() returning false it should exit.
If a command was not canceled then the next thing it tries is to clear all selection.
If there was no selection cleared then it will turn off points.
> How can I terminate the script rather than just canceling the CPlane tool?
There isn't currently any way for a script to know if moi.View.setCPLaneInteractive(); was cancelled or not but I will see about fixing that up and making it return false if canceled.
> Is there a standalone interactive Orientation Picker I can call that doesn't have the cancel
> button and that sets a coordinateFrame, but not a CPlane?
Yes, there is the general orientation picker you can call that is not directly wired into setting the cplane.
There's a wrapper for it in GetOrientation.js . It would go something like this (warning untested code):
var picker = moi.ui.createOrientationPicker();
if ( !GetOrientation( picker, 'BasePrompt1', 'BasePrompt2' ) )
return;
It's used in the Orient.js command. it has a .frame property to get the picked frame from it after it has finished.
- Michael
|