How to get max value from number slider?

I have a number slider with integer values. Now, I want to use the max value from that slider as 100% in a different operation. How do I output the max value from the number slider?

You could try popping this into a GHPython component. Where Input[0] represents the top/first input in the ghpython component (x in the screenshot), and there is only 1 source plugged in, (your number slider with integer values).

import Rhino

print ghenv.Component.Params.Input[0].Sources[0].TickCount

1 Like

Thank you! (Found it.)

Also, wow, I thought this was a super basic question, but already it seems I’ve stumbled on something that requires a super advanced solution.

Is there any other way one normally inputs min/max/interval numbers into Grasshopper?

Strictly from a technical standpoint, (as far as I know…), there is no other way to capture the maximum value setting of a slider. (outside of a scripting component, C#, VB, ghpython, or other specialized plugin).
With that said…would the maximum value of a slider ever change for some reason?

The most basic way to input min/max interval numbers would probably be to just use the construct domain component? You input min, max, and it outputs an interval…

No, it probably wouldn’t change since I can just set it crazy high, but I also can’t ever see it unless I open the slider editor, which is bad.

Can I ask what node you used to output the value with, because I used the param viewer node and that didn’t display correctly.

Plus, one final detail, your script actually seems to output the range, not the max, but adding +1 to it fixed that.

Oh, and can I also ask how to get the nice colored icon in the node like in your screenshot? Mine only has text.

ah, that’s fair, I just looked quickly. My slider was set from 0 to 50. Let me see if there is another property that might specifically have the max value.
Also, the node connected to the output value is a panel.

In GH, go to Display->Draw Icons to draw the icons. This will change the display for all components. You can also do it on a per component basis by right clicking the component, and click the little paint bucket next to the component name to toggle through some options.

1 Like

Try this one. I didn’t dig down enough to get to the proper object.

sourceSlider = ghenv.Component.Params.Input[0].Sources[0].Slider
print sourceSlider.Maximum

also, I would guess that something like Human or Metahopper (pre built plugins) , might already have some of this type of stuff built in.

2 Likes

Wonderful, thanks again!