Auto configuration of the number slider, c# - Grasshopper2024-03-28T18:07:04Zhttps://www.grasshopper3d.com/forum/topics/auto-configuration-of-the-number-slider-c?commentId=2985220%3AComment%3A1301626&x=1&feed=yes&xn_auth=noDavid - beautiful stuff - wor…tag:www.grasshopper3d.com,2015-06-02:2985220:Comment:13016262015-06-02T20:02:05.698ZTreehttps://www.grasshopper3d.com/profile/Tree
<p>David - beautiful stuff - works like a charm!</p>
<p>David - beautiful stuff - works like a charm!</p> Sliders don't have sources, t…tag:www.grasshopper3d.com,2015-06-02:2985220:Comment:13016242015-06-02T19:39:25.513ZDavid Ruttenhttps://www.grasshopper3d.com/profile/DavidRutten
<p>Sliders don't have sources, they only have recipients.</p>
<p></p>
<p>If you wish to find all sliders that are directly plugged into a component, you can use the following (untested) code:</p>
<p></p>
<p>List<GH_NumberSlider> sliders = new List<GH_NumberSlider>();</p>
<p>foreach (IGH_Param param in Params.Input)</p>
<p> foreach (IGH_Param source in param.Sources)</p>
<p> {</p>
<p> GH_NumberSlider slider = source as GH_NumberSlider;</p>
<p> if (slider != null)</p>
<p> …</p>
<p>Sliders don't have sources, they only have recipients.</p>
<p></p>
<p>If you wish to find all sliders that are directly plugged into a component, you can use the following (untested) code:</p>
<p></p>
<p>List<GH_NumberSlider> sliders = new List<GH_NumberSlider>();</p>
<p>foreach (IGH_Param param in Params.Input)</p>
<p> foreach (IGH_Param source in param.Sources)</p>
<p> {</p>
<p> GH_NumberSlider slider = source as GH_NumberSlider;</p>
<p> if (slider != null)</p>
<p> sliders.Add(slider);</p>
<p> }</p> David,
A sincere thank you.…tag:www.grasshopper3d.com,2015-06-02:2985220:Comment:13015232015-06-02T19:22:05.007ZTreehttps://www.grasshopper3d.com/profile/Tree
<p>David,</p>
<p></p>
<p>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?</p>
<p></p>
<p>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.</p>
<p></p>
<p>slider.Sources.IndexOf(Params.Input[0].Sources[0]);</p>
<p></p>
<p></p>
<p>BTW: I have managed to track down…</p>
<p>David,</p>
<p></p>
<p>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?</p>
<p></p>
<p>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.</p>
<p></p>
<p>slider.Sources.IndexOf(Params.Input[0].Sources[0]);</p>
<p></p>
<p></p>
<p>BTW: I have managed to track down the events previously mentioned (and for everyone's reference they look like this - see below). </p>
<p></p>
<p>Params.Input[indexhere].ObjectChanged += namespacehere_ObjectChanged; </p>
<p></p>
<p></p>
<p></p> Params.Input[0].Sources[0];tag:www.grasshopper3d.com,2015-06-02:2985220:Comment:13016132015-06-02T18:48:21.635ZDavid Ruttenhttps://www.grasshopper3d.com/profile/DavidRutten
<p>Params.Input[0].Sources[0];</p>
<p>Params.Input[0].Sources[0];</p> Huaxiamengqing,
By chance ca…tag:www.grasshopper3d.com,2015-06-02:2985220:Comment:13016112015-06-02T18:33:20.000ZTreehttps://www.grasshopper3d.com/profile/Tree
<p>Huaxiamengqing,</p>
<p></p>
<p>By chance can you assist with the c# equivalent of this code?</p>
<p></p>
<p>Component.Params.Input.First.Sources(0);</p>
<p></p>
<p>I understand the rest but am having trouble finding the equivalent conversion.</p>
<p>Huaxiamengqing,</p>
<p></p>
<p>By chance can you assist with the c# equivalent of this code?</p>
<p></p>
<p>Component.Params.Input.First.Sources(0);</p>
<p></p>
<p>I understand the rest but am having trouble finding the equivalent conversion.</p> Huaxiamengqing - Thank you!
tag:www.grasshopper3d.com,2015-06-02:2985220:Comment:13013572015-06-02T16:37:26.550ZTreehttps://www.grasshopper3d.com/profile/Tree
<p>Huaxiamengqing - Thank you!</p>
<p></p>
<p>Huaxiamengqing - Thank you!</p>
<p></p> Private Sub RunScript(ByVal x…tag:www.grasshopper3d.com,2015-06-02:2985220:Comment:13010472015-06-02T06:09:44.952Zhuaxiamengqinghttps://www.grasshopper3d.com/profile/huaxiamengqing
<p>Private Sub RunScript(ByVal x As Object, ByRef A As Object) <br></br> Static i As Integer = 0<br></br> i += 1000<br></br> Dim Slider As Grasshopper.Kernel.Special.GH_NumberSlider = Me.Component.Params.Input.First.Sources(0)</p>
<p>Slider.Slider.Maximum = 100<br></br> Slider.Slider.Minimum = 0<br></br> Slider.Slider.Type = Grasshopper.GUI.Base.GH_SliderAccuracy.Float<br></br> Slider.Slider.DecimalPlaces = 3<br></br> Slider.TickValue = i<br></br> ' Slider.SetSliderValue(GH_Skin.canvas_shade_size)<br></br> Slider.NickName = "By…</p>
<p>Private Sub RunScript(ByVal x As Object, ByRef A As Object) <br/> Static i As Integer = 0<br/> i += 1000<br/> Dim Slider As Grasshopper.Kernel.Special.GH_NumberSlider = Me.Component.Params.Input.First.Sources(0)</p>
<p>Slider.Slider.Maximum = 100<br/> Slider.Slider.Minimum = 0<br/> Slider.Slider.Type = Grasshopper.GUI.Base.GH_SliderAccuracy.Float<br/> Slider.Slider.DecimalPlaces = 3<br/> Slider.TickValue = i<br/> ' Slider.SetSliderValue(GH_Skin.canvas_shade_size)<br/> Slider.NickName = "By huaxia from SEG"<br/> a = Slider<br/> End Sub</p>