Control the min max and step of a number slider with three sliders?

Is it possible to control the min max and step of a number slider with three sliders? Similar to what’s requested here:

Hello,
you can try via this approach but there are such custom nodes (I think data shapes has one)

edit:

Cordially
christian.stan

1 Like

There are many solutions which work using OOTB nodes so they function for generative design. All of them require math plugging into a code block. Can’t look up my full set at the moment (not that they are well organized to even do so), but the outline below should help you get sorted.

My basic inputs, not that I always use them all or that they are always named like this, but it should give you some understanding.

Slider 1: min (any value smaller than max)
Slider 2: max (any value bigger than min)
Slider 3: step (any positive value)
Slider 4: percent (between 0 and 1)
Slider 5: offsets (any integer greater than 1)

Now for the code blocks.

  1. This solution ignores the step, but I find that often that is not needed in my work:
    (max-min)*percent + min;. The intent here is to find the distance between the two values, grab a value at a % of that number, and add it to the minimum. So with a min of 10, max 20, and a percent of 0.5 you get: (20-10)*0.5 +10; which evaluates to 15.
  2. This solution works with the step, but ignores the max: min+ offsets*step;. The intent here is to multiply the step value by the number of offsets and join it to the minimum value. With a min of 10 a step of 2 and an offset of 3 you get: 10+3*2;, which evaluates to 16.
  3. This solution works with all values but requires multiple lines and building the full range (not ideal for obscenely large design spaces): rng = min..max..step; rng[DSCore.List.Count(rng)*percent)]; Then intent here is to calculate all possible values by building a range, and then getting the value closest to the percent value of the range length. With values of min=10, max=20, step=2, percent=0.5 we get: rng =10..20..2; which evaluates to [10,12,14,16,18,20], and so the next line becomes [10,12,14,16,18,20][6*0.5]; which evaluates to 16.

There are other ways too - basically if you can math it and adjust the formula you can set it up to work with one or two code blocks. No need for sliders with inputs.

2 Likes

@jacob.small Thank you for this detailed explanation. This approach will work.

Also thanks to @christian.stan, I was looking into data shapes but in that case the sliders appear after you run the dynamo script (which is still useful in most cases but I was looking for something before running the dyn script). Thank you both.

2 Likes