Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Change the domain of an existing slider with a given NickName.
Reset a named slider's domain.
Sliders: List of slider NickNames.
Min: Minimum Value(s).
Max: Maximum value(s).
Update: Set to 'True' to update the slider's domain.
# Name component
ghenv.Component.Name = "Slider Domain Updater"
ghenv.Component.NickName = 'Slider Updater'
# Import libraries
import Grasshopper as gh
# Create list of domain values
Values = [Min, Max]
# Get GH objects
gh_objects = ghenv.Component.OnPingDocument().Objects
# Set 'Update' toggle
if Update:
# Iterate objects
for obj in gh_objects:
# Find components with given NickNames
if obj.NickName in Sliders:
# Get [Number Slider] objects with NickNames
if type(obj) is gh.Kernel.Special.GH_NumberSlider:
# Set minimum and maximum values
obj.Slider.Minimum = Min
obj.Slider.Maximum = Max
# Set values
obj.Slider.Value = Values[Sliders.index(obj.NickName)]
# Update sliders
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.