Grasshopper

algorithmic modeling for Rhino

I have created my own component who's only output is a list of curves.

Unfortunately the algorithm that produces them is somewhat expensive (anything from 10s to a minute to calculate depending on the inputs).

As I have it currently the component takes a boolean input. If false the component just returns. If true the algorithm runs. When set to false the output list of curves is cleared, preventing any manipulation by downstream components that the user may want to fiddle with.

What I would like to do is cache my results, so when false the output curve list is still populated with the previous runs and downstream components can act on them.

Has anyone tried this? Is there some obvious way of doing this that I am overlooking?

Views: 143

Replies to This Discussion

You could maintain a local list of curves as a private class variable, populate it synchronously while input=true and output it directly if output=false.

That worked and was really easy to implement. Cheers!

In python you could add your last returned curves to the sticky dictionary, and then check whether the new output returns some curves or Null. If case of the later one, you can call the sticky, and take curves from the last return.
Are you coding this in C#?

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