Grasshopper

algorithmic modeling for Rhino

I have a custom component that sets parent/child relationships in a nodal network.

If data is added my system works, however if data is deleted (e.g. curve deleted from list of inputs or disconnected) it fails to work.

There can be several of these components that are unaware of one another so I cannot just clear the data and add to it afresh.

If I perform a manual recompute (F5) it solves my problems.

Is there a way I can force a full recompute from within my code? I am aware of NewSolution but not sure about how I could go about implementing it (would I not end up in a never ending loop? I am also struggling to find out how to get the active grasshopper document from within the code of my component).

Any help would be very much appreciated.

Views: 1988

Replies to This Discussion

Yes you can, here are the steps:

  • When you change date inside a parameter or add/remove a wire, you must call ExpireSolution(false) on that object. You can call ExpireSolution(false) as often as you like, only the first call will actually do anything.
  • When you are done making all changes, call NewSolution(false) on the GH_Document. This will cause all expired object to recompute (but not the intact ones).

F5 calls GH_Document.ExpireSolution(true), which first expires all objects prior to recomputing. You do not need this kind of sledgehammer approach.

--

David Rutten

david@mcneel.com

Thank you for the reply David.

Excuse me for being a bit stupid, but would you mind posting a code snippet (preferably C#) retrieving the active GH_Document and calling NewSolution(false)?

Found out how to do it, for anyone in the future it is in:

Grasshopper.Instances.ActiveCanvas.Document

Hi, 

i have the same Poblem here... can someone please post a little code snipped how that would look like?

Thanks a lot!

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