Number Slider and Input parameters

Hello.
Is there an additional Number Slider in the Grasshopper in which the range of values ​​would not be set manually, but would be obtained from the results of the calculations?

In this example, I would like to take a numerical value from the calculated curve length and assigned in a Number Slider.

Is it possible?
Thanks in advance

Number Slider.gh (7.3 KB)

well, the need of something like that was felt already 10+ years ago :slight_smile:

this is not exactly what you are looking for, but maybe it’s helpful or inspiring
you could also consider to insert some rounding in such a way to get sharper values

Number Slider_inno.gh (10.1 KB)


if you are happy to use code, check also this from the answer in the above thread: Remotely change the value of any number slider in Grasshopper with C# - James Ramsden

2 Likes

Hi inno!
This is an elegant solution, thank you very much.
But I became interested in your link to the dynamic slider.

It would be cool to be able to automatically set to numeric domain for a min/max values in slider.
The thing is that in my example the curve is not static, it will change its size.
I would like to see in the slider the values ​​in millimeters.

I tried to play with the script, but it does not work for me. 10 years have already passed, and code is presented on the site, which may not be supported.

private void RunScript(object x, double y, ref object A)
  {
    var input = Component.Params.Input[0].Sources[0]; //get the first thing connected to the first input of this component
    var slider = input as Grasshopper.Kernel.Special.GH_NumberSlider; //try to cast that thing as a slider

    if(slider != null) //if the component was successfully cast as a slider
    {
      slider.Slider.Minimum = 0;
      slider.Slider.Maximum = y;
    }
  }

I also saw a topic where you participated in the discussion of a similar issue. In one of the examples, the slider receives data, but within a manually set value range.

Number Slider min and max values.gh (10.9 KB)

1 Like


set slider minmax.gh (4.1 KB)

private void RunScript(object slider, double min, double max)
  {
    decimal mi = (decimal) min;
    decimal ma = (decimal) max;
    Grasshopper.Kernel.Special.GH_NumberSlider sli = this.Component.Params.Input[0].Sources[0] as Grasshopper.Kernel.Special.GH_NumberSlider;
    if(sli.Slider.Minimum != mi) sli.Slider.Minimum = mi;
    if(sli.Slider.Maximum != ma) sli.Slider.Maximum = ma;
    if(sli.CurrentValue < mi)sli.TrySetSliderValue(mi);
    if(sli.CurrentValue > ma)sli.TrySetSliderValue(ma);
  }
3 Likes

Hi Riccardo,
This is exactly what I was looking for!
It is very useful tool.
I’m really thankful to you, thank you a lot. :handshake: