Hi Peer,
re:
> Second, how can I safely re-prompt a user for input? If I run the script below, set the
> CPlane at the wrong orientation, and then hit Esc on the next iteration through the
> While loop it goes into an infite loop. It's like the line moi.View.setCPLaneInteractive();
> is getting skipped over, but the While loop is still running.
What's happening is when you hit Esc or the Cancel button it's trying to cancel the current running command. This sets a "pending cancel command" state.
When moi.view.setCPlaneInteractive() goes into its internal event loop it sees that there is a pending cancel for the current command, and it immediately exits but there isn't a way currently for the script to know about that and so the script continues its while loop. With the next beta where moi.view.setCPlaneInteractive() will return false if it was canceled you can then update this script to have:
code:
// user picks orientation of new CPlane
if ( !moi.View.setCPLaneInteractive() )
break;
If you use the orientation picker directly instead of moi.view.setCPlaneInteractive() you'll have your own event loop and you should be able to see a cancel when picker.waitForEvent() returns false. On the orientation picker you can also call picker.allowNestedCancel() which will then cause Esc or the Cancel button to cancel just that picker's wait instead of doing a full command cancel which is the default behavior.
I'll see about adding in an optional boolean to moi.view.setCPLaneInteractive() so you can set it to do a nested cancel as well.
- Michael
|