Grasshopper

algorithmic modeling for Rhino

esc not detected in ghPython + weird behaviour with scriptcontext.escape_key()

Dear all,

2 questions (1 question and 1 observation really):

1. esc keypress not detected in ghPython:

I was trying to use the escape key to break a loop from within the ghpython component, following this tutorial https://discourse.mcneel.com/t/stopping-a-conditional-loop-with-the....

It seems to only work in rhino's editpythonscript and not in ghPython in the gh canvas. swapping ghdoc to rhino.activedoc doesn't seem to do anything either.

So is there an actual method that detects the ESC key to break a ghPython loop from within ghcanvas?

2. unintended (but nice) behaviour when sc.escape_test() is thrown into the loop:

When i throw sc.escape_test() into a loop in ghPython, rhino's viewport seems to update results per loop, while it just freezes without it and outputs a final result.

here's a nice GIF to illustrate the behavior:

no gh timers!

Regards,

Li Qun

Views: 500

Replies to This Discussion

Hi Li Qun,

thanks for reporting this.

You can get the feedback that you request by using the Grasshopper SDK:

Grasshopper.Kernel.GH_Document.IsEscapeKeyDown()

See here an example. I also fixed this in Rhino WIP, so that this works more generally in Rhino using the scriptcontext function.

Thanks again for your valuable input,

Giulio
--
Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com

PS: The unintended (but nice) behavior is due to the SDK function EscapePressed(), that needs to keep the message pump alive so that it can see if there are ESC messages coming in from Windows.

Attachments:

works like a charm!

i was helpless against the second component until it ended and then saw the console saying my WIP is too old. XD

i've added a raise SystemExit to your v6 just in case someone else came along, tried it with v5 and freaked out haha..

Attachments:

Time to try this week's Rhino WIP :)

Yes. I think this has to do with Grasshopper 'noticing' the push of the ESC key, but only David R. can tell.

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service