Grasshopper

algorithmic modeling for Rhino

Hi everyone!

How to create a method that works like a button to reset kangaroo2 solver? I am working on c# script component and I am trying to use the Slider.VaueChanged event. The event handler seems works but then how to create a boolean value that has falsevalue before i move the slider, and then it becomes true everytime the value changes and back to false right after it. Here is my script so far and I really appreciate any help. Thank you very much!

Best, Akbar. 

private void RunScript(List<double> Sliders, ref object A)
{

List<IGH_ActiveObject> ListOfSliders = new List<IGH_ActiveObject>();

foreach(IGH_Param par in Component.Params.Input[0].Sources)
{
foreach(IGH_ActiveObject obj in this.Component.OnPingDocument().ActiveObjects())
{
if (par.InstanceGuid == obj.InstanceGuid) ListOfSliders.Add(obj);
}
}

foreach(IGH_ActiveObject slider in ListOfSliders){

Grasshopper.Kernel.Special.GH_NumberSlider sldr = (Grasshopper.Kernel.Special.GH_NumberSlider) slider;
sldr.Slider.ValueChanged += OnValueChanging;
}

A = reset;

}

// <Custom additional code>
bool reset = false;

void OnValueChanging(object sender, Grasshopper.GUI.Base.GH_SliderEventArgs e)
{

What to do here????


}

Views: 339

Replies are closed for this discussion.

Replies to This Discussion

Why not to use [StepSolver] instead of the regular [Solver] component?

In his description appears:

"Solver which advances only when input refreshed. Useful for making animations".

And you can also refresh it by plugin a [timer] in a [slider] if you wish.


RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service