# How to reference to GH\_Silder in Plugin Grasshopper?

**URL:** <https://discourse.mcneel.com/t/how-to-reference-to-gh-silder-in-plugin-grasshopper/111257>\
**Category:** Grasshopper Developer\
**Tags:** rhino6, c, grasshopperrhino\
**Created:** [October 30, 2020, 4:27am UTC](https://discourse.mcneel.com/t/how-to-reference-to-gh-silder-in-plugin-grasshopper/111257 "2020-10-30T04:27:21Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![nghiiatran1998](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/nghiiatran1998/32/256629_2.png) [@nghiiatran1998](https://discourse.mcneel.com/u/nghiiatran1998)\
**Post date:** [October 30, 2020, 4:27am UTC](https://discourse.mcneel.com/t/how-to-reference-to-gh-silder-in-plugin-grasshopper/111257/1 "2020-10-30T04:27:21Z")

</div>

Hi everyone,  
I have application code c#, I used GH\_Chunks to find chunks “Silder” and get value display on application: This is your code:

```auto
for (int f = 0; f < folderGrArray.Length; f++)
                    {
                        archive.ReadFromFile(folderGrArray[f]);
                        GH_Chunk rootNode = archive.GetRootNode;
                        GH_Chunk definitionChunk = rootNode.FindChunk("Definition") as GH_Chunk;
                        GH_Chunk definitionObjChunk = definitionChunk.FindChunk("DefinitionObjects") as GH_Chunk;
                        int objectCount = definitionObjChunk.GetInt32("ObjectCount");
                        GH_Chunk objectChunks = definitionChunk.FindChunk("Object", 2) as GH_Chunk;
                        for (int i = 0; i < objectCount; i++)
                        {
                            GH_Chunk objectChunk = definitionObjChunk.FindChunk("Object", i) as GH_Chunk;
                            for (int chuck1 = 0; chuck1 < objectChunk.Chunks.Count; chuck1++)
                            {
                                GH_Chunk objectChunk1 = definitionChunk.FindChunk("Object", i) as GH_Chunk;
                                string name = objectChunk.GetString("Name");
                                //This may not be foolproof - probably better to check the object GUID
                                if (name == "Number Slider")
                                {
                                    GH_Chunk containerChunk = objectChunk.FindChunk("Container") as GH_Chunk;
                                    GH_Chunk sliderChunk = containerChunk.FindChunk("Slider") as GH_Chunk;
                                    string sliderValue = sliderChunk.GetDouble("Value").ToString();
                                    string silderDigits = sliderChunk.GetInt32("Digits").ToString();
                                    string silderGrip = sliderChunk.GetInt32("GripDisplay").ToString();
                                    string silderInterval = sliderChunk.GetInt32("Interval").ToString();
                                    string snap = sliderChunk.GetInt32("SnapCount").ToString();
                                    string min = sliderChunk.GetDouble("Min").ToString();
                                    string max = sliderChunk.GetDouble("Max").ToString();

                                    SilderObject sliderObj = new SilderObject()
                                    {
                                        DIGITS = sliderChunk.GetInt32("Digits").ToString(),
                                        GRIPDISPLAY = sliderChunk.GetInt32("GripDisplay").ToString(),
                                        INTERVAL = sliderChunk.GetInt32("Interval").ToString(),
                                        MAX = sliderChunk.GetDouble("Max").ToString(),
                                        MIN = sliderChunk.GetDouble("Min").ToString(),
                                        SNAPCOUNT = sliderChunk.GetInt32("SnapCount").ToString(),
                                        VALUE = sliderChunk.GetDouble("Value").ToString()
                                    };
                                    lstSilder.Add(sliderObj);
                                }
                            }
                        }
                        label1.Text = "Value Silder 1";
                        numUDSilder1.Maximum = Convert.ToDecimal(lstSilder[0].MAX);
                        numUDSilder1.Minimum = Convert.ToDecimal(lstSilder[0].MIN);
                        numUDSilder1.Value = Convert.ToDecimal(lstSilder[0].VALUE);

                        lblSilder1.Text = "Value Silder 2";
                        numUDSlider2.Maximum = Convert.ToDecimal(lstSilder[1].MAX);
                        numUDSlider2.Minimum = Convert.ToDecimal(lstSilder[1].MIN);
                        numUDSlider2.Value = Convert.ToDecimal(lstSilder[1].VALUE);

                        lblSlider2.Text = "Value Silder 3";
                        numSilder3.Maximum = Convert.ToDecimal(lstSilder[2].MAX);
                        numSilder3.Minimum = Convert.ToDecimal(lstSilder[2].MIN);
                        numSilder3.Value = Convert.ToDecimal(lstSilder[2].VALUE);

                        label2.Text = "Value Silder 4";
                        numSilder4.Maximum = Convert.ToDecimal(lstSilder[3].MAX);
                        numSilder4.Minimum = Convert.ToDecimal(lstSilder[3].MIN);
                        numSilder4.Value = Convert.ToDecimal(lstSilder[3].VALUE);

                        label4.Text = "Value Silder 5";
                        numSilder5.Maximum = Convert.ToDecimal(lstSilder[4].MAX);
                        numSilder5.Minimum = Convert.ToDecimal(lstSilder[4].MIN);
                        numSilder5.Value = Convert.ToDecimal(lstSilder[4].VALUE);

                        label3.Text = "Value Silder 6";
                        numSilder6.Maximum = Convert.ToDecimal(lstSilder[5].MAX);
                        numSilder6.Minimum = Convert.ToDecimal(lstSilder[5].MIN);
                        numSilder6.Value = Convert.ToDecimal(lstSilder[5].VALUE);

```

Now, how do I not know the reference value from textBox to object GH\_Silder?  
Please support me,  
Best regards.

---

<div class="post-metadata">

**Author:** ![DavidRutten](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/davidrutten/32/755688_2.png) [@DavidRutten](https://discourse.mcneel.com/u/DavidRutten)\
**Post date:** [October 30, 2020, 6:33am UTC](https://discourse.mcneel.com/t/how-to-reference-to-gh-silder-in-plugin-grasshopper/111257/2 "2020-10-30T06:33:13Z")

</div>

I don’t understand the question, can you elaborate?

---

<div class="post-metadata">

**Author:** ![nghiiatran1998](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/nghiiatran1998/32/256629_2.png) [@nghiiatran1998](https://discourse.mcneel.com/u/nghiiatran1998)\
**Post date:** [October 30, 2020, 6:40am UTC](https://discourse.mcneel.com/t/how-to-reference-to-gh-silder-in-plugin-grasshopper/111257/3 "2020-10-30T06:40:08Z")

</div>

Thanks for the answer, I apologize for the question that is not clear

I change the value textbox on my application and I want to reference this value to the slider on the grasshopper, Is there a way to do this?

Regards

---

<div class="post-metadata">

**Author:** ![DavidRutten](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/davidrutten/32/755688_2.png) [@DavidRutten](https://discourse.mcneel.com/u/DavidRutten)\
**Post date:** [October 30, 2020, 9:03am UTC](https://discourse.mcneel.com/t/how-to-reference-to-gh-silder-in-plugin-grasshopper/111257/4 "2020-10-30T09:03:21Z")

</div>

Okay, now I get it. You sure you want to write the value back to the `*.gh` file, and not the loaded `GH_Document`? Both are possible, but require very different approaches.

---

<div class="post-metadata">

**Author:** ![nghiiatran1998](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/nghiiatran1998/32/256629_2.png) [@nghiiatran1998](https://discourse.mcneel.com/u/nghiiatran1998)\
**Post date:** [October 30, 2020, 10:34am UTC](https://discourse.mcneel.com/t/how-to-reference-to-gh-silder-in-plugin-grasshopper/111257/5 "2020-10-30T10:34:53Z")

</div>

Can you guide me in 2 ways?, I will learn and apply the best way for my application.  
Thanks.

---

<div class="post-metadata">

**Author:** ![DavidRutten](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/davidrutten/32/755688_2.png) [@DavidRutten](https://discourse.mcneel.com/u/DavidRutten)\
**Post date:** [October 30, 2020, 1:42pm UTC](https://discourse.mcneel.com/t/how-to-reference-to-gh-silder-in-plugin-grasshopper/111257/7 "2020-10-30T13:42:09Z")

</div>

[FileWithSliders.gh](https://discourse.mcneel.com/uploads/short-url/iW0vhR6kNpcux2yqxAtfuZ3SxVa.gh) (4.9 KB)  
[AssignSlidersInFile.gh](https://discourse.mcneel.com/uploads/short-url/2p1LDy3NRr5DzGtyYGM7orJRW93.gh) (5.5 KB)  
[AssignSlidersInDocument.gh](https://discourse.mcneel.com/uploads/short-url/ljSIJHWgZX1ZTURV4wGWRvwmPEQ.gh) (6.5 KB)

The third file modifies the sliders of the document which contains the script component. If you run your code not from ‘inside’ the document but from some sort of UI event handler, you do not need the scheduling logic. You can just directly modify the GH\_Document.

---

<div class="post-metadata">

**Author:** ![nghiiatran1998](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/nghiiatran1998/32/256629_2.png) [@nghiiatran1998](https://discourse.mcneel.com/u/nghiiatran1998)\
**Post date:** [November 1, 2020, 9:28am UTC](https://discourse.mcneel.com/t/how-to-reference-to-gh-silder-in-plugin-grasshopper/111257/8 "2020-11-01T09:28:42Z")

</div>

ok, Thanks your answer  
I will try it.

Best regards.
