Acknowledging Abort request (Escape)

 

Hi,

 

I've had a user request for my plugin to acknowledge a computation abort request when the user presses escape.  I'm assuming there is probably an event raised, and that I'll have to spawn a worker thread to do the calculation.  Is this possible and is there any examples of achieving this?

 

Thanks in advance,

 

Jon

  • up

    David Rutten

    Hi Jon,

     

    I don't get it, are you looking to abort the solution or are you looking to abort your portion of the solution if an Escape has been pressed?

     

    Have a look at the following methods, see if it helps you out:

     

    GH_Document.RequestAbortSolution()   (this sets the abort flag to true)

    GH_Document.AbortRequested             (gets the value of the abort flag)

    GH_Document.IsEscapeKeyDown()        (static/shared method to test the state of Escape)

     

    Don't call IsEscapeKeyDown() too often, it does take some cycles to measure it. Also, it will print a message in the command line if it is down ("Escape key abort"). Furthermore, it will only work if the Grasshopper window has focus. I don't want to respond to Escape key presses that happen in other application while Grasshopper is churning away.

     

     

    When an Abort has been requested, Grasshopper will not solve the next object in the queue, and it's possible that specific objects also handle this logic inside their own Solution methods (Components for example check the Escape state while they iterate over their data).

     

    --

    David Rutten

    david@mcneel.com

    Poprad, Slovakia

    2