Skip to content

Instantly share code, notes, and snippets.

@StepMaher
Last active November 4, 2015 21:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save StepMaher/3d79ba82c24806822812 to your computer and use it in GitHub Desktop.
Save StepMaher/3d79ba82c24806822812 to your computer and use it in GitHub Desktop.
Change the domain of an existing slider with a given NickName.
"""
Reset a named slider's domain.
Inputs:
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
obj.ExpireSolution(True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment