Grasshopper

algorithmic modeling for Rhino

Hello!

I have created some specialized parameters (derived from GH_Param), dependent of high-level objects included in the Rhino document. Each time the Rhino file change (.3dm Open/New) these parameters should be notified to be recalculated.

Is there some event like GH_Param::OnRhinoDocChange () or similar?

Thank you very much!

Views: 703

Replies to This Discussion

Yes there is...the event you're searching for is called "EndOpenDocument".

All events you should take a look at, are in RhinoCommon Class RhinoDoc.

Best regards FF

Thanks Florian, but... how can I notify these changes to GH_Param?

When you detect an event in Rhino that you want to respond to. You can expire your parameters and trigger a new solution. Basically call ExpireSolution(false) on every affected parameter and when you're done call NewSolution(false) on the GH_Document.

If it's likely that a single event will be followed by further events, then you may want to create a timer that delays your expiration/recalculation calls for a few milliseconds to see if there's any other events happening.

There is already a mechanism for this sort of thing in Grasshopper as Points, Curves, Surfaces, Meshes, Boxes and Breps all respond to changes. Is it not possible to make your own data use this mechanism? Or are you not dealing with custom IGH_Goo here at all?

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Thank you very much for your answers and excuse my lack of experience in programming with Grasshopper ;)

But... How I can capture RhinoDoc events in Grasshopper?
In my project, all classes derived from GH_Param, GH_Component and IGH_GeotricGoo.

Should I create a high-level class that controls the document?

Sorry, it seems I was confused. Are you only looking to respond to document swaps or also to changes to document objects. I assume you're referencing objects or data from the 3dm file that people can change right? So do you also want to respond to those kind of changes?

--

David Rutten

david@mcneel.com

Poprad, Slovakia

That is, David.

The .3dm document includes high level objects (non-geometric) that I have encapsulated in GH components derived from GH_Param. I need to detect when the .3dm changes to recalculate these parameters.

Ok, then Florian's answer is what you need.

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Hi Francisco,

Bind the event where you need to (e.g. on placing the component on the canvas)...like this:

RhinoDoc.EndOpenDocument += new EventHandler(myEventHandler);

When the component has been removed from the canvas...unbind the event:

RhinoDoc.EndOpenDocument -= new EventHandler(myEventHandler);

This is your EventHandler

private void myEventHandler(object sender, Rhino.DocumentOpenEventArgs args){
    //Do your stuff
  }

hope this helps

Cheers FF

Ok!, that's work perfectly

Thank's a million!

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service