Grasshopper

algorithmic modeling for Rhino

Hi guys,

I tried to postpone passing data through a component, same as what DataDam does, 

I've used ScheduleSolution and cullback but there is somthing wrong with the process .

the problem is that if I miss DA.SetData the component gets null while taking the latency , on the other hand if use it the component has two kicks , is there anyway to get rid the first kick?

GH_Structure<IGH_Goo> D = new GH_Structure<IGH_Goo>();
GH_Structure<IGH_Goo> C = new GH_Structure<IGH_Goo>();
protected override void SolveInstance(IGH_DataAccess DA)
{

bool sw = false;
int delay = 0;
DA.GetData(1, ref delay);
DA.GetData(2, ref sw);
DA.GetDataTree(0, out D);
DA.SetDataTree(0, C);

if (sw) C = D.Duplicate();

if (delay > 4)

base.OnPingDocument().ScheduleSolution(delay, cullback);

}

private void cullback(GH_Document doc)
{
var gate=base.Params.Output[0];
gate.ClearData();
gate.AddVolatileDataTree(C);
foreach (IGH_Param i in gate.Recipients)
i.ExpireSolution(false);
}

Views: 389

Replies to This Discussion

You may also want to override the expiration logic of your component and *not* expire the output when the input expires. That should get rid of one of the iterations. You'll have to make sure to expire the output from your Callback method though.

Also note that when you schedule a solution for N milliseconds in the future, if a solution is triggered before this period of time passes your callback will also be invoked. So if you attach this component to a slider, it will not really delay the data much at all because the slider keeps triggering new solutions while it's being dragged. You'll probably have to keep track of how much time passed when your callback is invoked to see if you're meant to update the output.

I'd tried to use ExpireSolution for both the component ether the output parameter before ,but , I think I  used it in the wrong way because in some cases the rhino crashed and in others nothing happend. is there any other method in GH library specified for such cases or just have to find a logic with ExpireSolution?

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