Grasshopper

algorithmic modeling for Rhino

Hi everyone,

does anyone happen to have a script laying around that can replace old sliders with new ones, so that the slider labels are automatically populated with the connected input name?

Kind regards,
Pieter

Views: 327

Replies to This Discussion

Hi Pieter - 

Try the attached. It will set the nickname of all sliders in the document to be an empty string, which causes them to automatically take on the names of the inputs they're plugged into. I've also left a few lines commented, which you can add if you want the script to only affect sliders that are currently called "Slider" (and ignore any sliders you've manually given names to).

Hope that helps!

var sliders = GrasshopperDocument.ActiveObjects().Where(o => o is Grasshopper.Kernel.Special.GH_NumberSlider).Cast<Grasshopper.Kernel.Special.GH_NumberSlider>();
foreach(Grasshopper.Kernel.Special.GH_NumberSlider slider in sliders){
// if(slider.NickName == "Slider"){
slider.NickName = "";
// }
}

Attachments:

Spot on Andrew, thank you so much! That does help indeed:)
Somehow I thought the older sliders were just incapable of this tagging functionality - hence the 'replace' question - but I'm glad you've proven me wrong (and I regret not getting around to try this myself). I guess my assumption was wrong because the older definitions simply use the current available Slider, right?
I uncommented the conditional statement, thanks for thinking along Andrew:) Cool:)

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service