Grasshopper

algorithmic modeling for Rhino

Event Handling - Best strategies for handling multiple events

Hello David / GH Development team,

I just raised this topic on the Rhino Developer forum but am also raising it here because it's clearly a grasshopper topic too. The question is  about event handling, in particular, how to best handle multiple 'simultaneous' events when they are triggered and what strategies are recommended.

An example of an event sequence might be this:

A user performs a 'join' on a collection of selected rhino geometry, say 20 objects, which results in the event sequence of an addition of one new object and then the deletion of the 20 previous objects. 

My questions has to do with handling these (rhino) events and how they might best fit into the grasshopper solution sequence from a performance point of view. 

In the above example what I find is that code which executes perfectly with a small number of events can become quite slow when a significant number of these 'simultanious' events occur.  

What strategies are recommended for reducing the above events instead of catching each of them?

One strategy that comes to mind is caching, also found in this example [here], but I'm curious what other strategies might be recommended.

Views: 560

Replies to This Discussion

This is tricky. Rhino object events are generally useless when it comes to actually responding to them. I've put in a request for a more generic ItsOkToDoStuffNow event, but I don't think they've added one yet. Here's how I handle events in GH:

  • AddObject, DeleteObject etc. are handled, but only in the sense that they delete caches or set 'dirty flags'.
  • Events like EndUndo, EndCommand etc. are handled and I actually do stuff here, but only if the dirty flag is set to true.

David,

Dale replied to my enquiry via the Rhino forum. He mentioned the RhinoApp.Idle event which worked well in conjunction with your flagging suggestions.

I agree with you that an ItsOk event would be very useful but it turns out that Idle seems to be a very good substitute. 

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service