algorithmic modeling for Rhino
David / GH team,
It is clear there are methods for components to read information from other components (ie. the slider can rename itself to reflect the name of the input it is attached to) but is it possible to send a number back and have the slider reflect that number?
1. If a number slider is connected to a component that ranges from 0 to 100 would it be possible to set that slider to a point between those two numbers - for example the number 50?
2. If a number slider is connect to a component that knows it's range - can it send that range to the slider to automatically configure it?
Thanks in advance.
NOTE: this discussion is being continued at this link [ here ].
Private Sub RunScript(ByVal x As Object, ByRef A As Object)
Static i As Integer = 0
i += 1000
Dim Slider As Grasshopper.Kernel.Special.GH_NumberSlider = Me.Component.Params.Input.First.Sources(0)
Slider.Slider.Maximum = 100
Slider.Slider.Minimum = 0
Slider.Slider.Type = Grasshopper.GUI.Base.GH_SliderAccuracy.Float
Slider.Slider.DecimalPlaces = 3
Slider.TickValue = i
Slider.NickName = "By huaxia from SEG"
a = Slider
Huaxiamengqing - Thank you!
By chance can you assist with the c# equivalent of this code?
I understand the rest but am having trouble finding the equivalent conversion.
A sincere thank you. I am receiving errors so I am clearly not implementing this correctly. How do I correctly assign Params.Input[indexhere].Sources[indexhere] to the slider?
For instance this code this would seem to make sense as a connector between the slider object and the input param but I clearly am not understanding something.
BTW: I have managed to track down the events previously mentioned (and for everyone's reference they look like this - see below).
Params.Input[indexhere].ObjectChanged += namespacehere_ObjectChanged;
Sliders don't have sources, they only have recipients.
If you wish to find all sliders that are directly plugged into a component, you can use the following (untested) code:
List<GH_NumberSlider> sliders = new List<GH_NumberSlider>();
foreach (IGH_Param param in Params.Input)
foreach (IGH_Param source in param.Sources)
GH_NumberSlider slider = source as GH_NumberSlider;
if (slider != null)
David - beautiful stuff - works like a charm!