Problem Controlling Range of Sliders with Python

grasshopper
python

#1

Hi, I been having some difficulties trying to change the range of multiple sliders using GhPython, as the range get reduce the ticks of the slider jumps out of the bar, I believe it has to do with the way I’m managing the solution, I was wondering if someone could take a look at the script and tell what I’m doing wrong. Thanks!!!
Control Sliders Python.gh (11.3 KB)


Dynamic input of min/max range of sliders?
(qythium) #2

Can you explain what you’re trying to achieve? The code has many problems and is difficult to understand.

To dynamcially set slider ranges you can use Metahopper plugin.
set_slider_properties.gh (3.1 KB)


#3

Hi qythium, well, I was trying to change the range of any slider connected to Input[1], an output the value of the sliders, is the same function that the definition of Metahopper, set_slider_properties.gh, but I need it to be internalize, I need to use those values for other parts of the script. I Believe it can be done with stickies but I’m not really sure…


(Giulio Piacentino) #4

Have a look if this helps:


(qythium) #5

Apart from Giulio’s solution, you can also try this hybrid approach with Metahopper:
set_silder_properties_v2.gh (8.6 KB)

slidermax = x**2 # however you want
sliders = ghenv.Component.Params.Input[1].Sources

#6

Hi, thanks for the help, at the end I choose the qythium approach because in that way I could control the range and change the names of the sliders at the same time. I tried to Internalize it, but it always end up with a ExpireSolution() problem at the start of the definition.

Deleuran Method: is good only for changing values, but it doesn’t let you change the name of the sliders
qythium Method: is good for changing values, an for changing the name of the sliders, an there is no necessity of renaming the slider after copy of the component

Here is the script used Range Slider Final.gh (8.8 KB)


(Giulio Piacentino) #7

The “expire solution problem” means that you are changing the solution during a solution: that is not possible. Methods that do that are bound to break erratically and should not be used.

If all you are after is changing the component “NickName” property, then modify the method I show on the other thread, and look up sliders by their “InstanceGuid” (first, print it, then use it).

Thanks,

Giulio


Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com


#8

You can set any mutable property of a slider using this (awesomely named) method, including NickName (I’m pretty sure).

180507_SetNamedSliders_GHPython.gh (6.1 KB)