Grasshopper

algorithmic modeling for Rhino

Hello,

I'm working in a .gha library that tranforms GH data into custom data (from custom classes). Then I have a final component that takes all the data and do some operations (it's a form-finding algorithm).

The problem is that when a start changing parameters of the form-finding components, the nodes coordinates changes as i move the sliders, but the geometry input shouldn't change. It's like every time I move the sliders all previous data follows the coordinates updates that solver component executes. That makes results crazy!

I know that in plugins like Karamba there are Copy Methods to avoid this kind of stuff, but i have no idea how to do that. Any help?

Thanks,

Márcio Sartorelli

Views: 446

Replies to This Discussion

When you get data from inputs that you're planning on changing, you must make your own copies first. IGH_Goo has methods for this, but you can also implement your own duplication logic. Grasshopper does not make copies of data when it is shared amongst parameters, as that could really bloat the memory usage.

You mean IGH_Goo method Duplicate()? I tryed to implement it by two ways, none of them worked:

public override IGH_Goo Duplicate()
{
GH_Model dup = new GH_Model();
dup.Value = Value;
return dup;
}

and

public override IGH_Goo Duplicate()
{
return new GH_Model(new Model());
}

In my Solver component is when I change input data, I make the copy that way:

protected override void SolveInstance(IGH_DataAccess DA)
{
GH_Model inmodel = new GH_Model();
if (!DA.GetData(0, ref inmodel)) return;
inmodel.Duplicate();
Model model = inmodel.Value;

What I'm doing wrong?

Also, inside Model class is many custom classes that I created, I need to duplicate each of them?

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