How to reference to GH_Silder in Plugin Grasshopper?

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:

for (int f = 0; f < folderGrArray.Length; 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()
                        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.

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

1 Like

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?


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.

Can you guide me in 2 ways?, I will learn and apply the best way for my application.
Thanks. (4.9 KB) (5.5 KB) (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.

ok, Thanks your answer
I will try it.

Best regards.