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?
For example:
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 ].
Tags:
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.SetSliderValue(GH_Skin.canvas_shade_size)
Slider.NickName = "By huaxia from SEG"
a = Slider
End Sub
Huaxiamengqing,
By chance can you assist with the c# equivalent of this code?
Component.Params.Input.First.Sources(0);
I understand the rest but am having trouble finding the equivalent conversion.
Params.Input[0].Sources[0];
David,
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.
slider.Sources.IndexOf(Params.Input[0].Sources[0]);
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)
sliders.Add(slider);
}
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by