# Wish: Get panel and slider properties in Grasshopper

**URL:** <https://discourse.mcneel.com/t/wish-get-panel-and-slider-properties-in-grasshopper/189445>\
**Category:** Serengeti (Rhino BETA)\
**Tags:** slider, metahopper, attributes, user-text, key-value\
**Created:** [August 13, 2024, 10:18am UTC](https://discourse.mcneel.com/t/wish-get-panel-and-slider-properties-in-grasshopper/189445 "2024-08-13T10:18:03Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Intuos](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/intuos/32/771015_2.png) [@Intuos](https://discourse.mcneel.com/u/Intuos)\
**Post date:** [August 13, 2024, 10:18am UTC](https://discourse.mcneel.com/t/wish-get-panel-and-slider-properties-in-grasshopper/189445/1 "2024-08-13T10:18:03Z")

</div>

For use with the User Text components, I would like to see two components that can read the properties of panels and sliders. That way, you can use the (nick)name of a panel/ slider and their values as Keys and Values respectively. Metahopper has a component that works for sliders, however, you cannot directly feed in the slider, nor does in expire when the slider’s name is changed – meaning you have to reselect it.

 ![afbeelding](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/0/7/a/07ac351b4953a46ca83446479769a5719b856ec5.jpeg)

[Panel and slider properties.gh](https://discourse.mcneel.com/uploads/short-url/tlDIw1YuQl5ptR3AfJ74WIDLI3x.gh) (23.5 KB)

---

<div class="post-metadata">

**Author:** ![seltzdesign](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/seltzdesign/32/512215_2.png) [@seltzdesign](https://discourse.mcneel.com/u/seltzdesign)\
**Post date:** [August 13, 2024, 11:55am UTC](https://discourse.mcneel.com/t/wish-get-panel-and-slider-properties-in-grasshopper/189445/2 "2024-08-13T11:55:04Z")

</div>

I usually prefer to use the “Get connected object” from Metahopper. That way you don’t have to select an object first using a button and it will always work.

You can then also use Object Info to get the nickname of any object, including a panel. The value is just the same value coming out of the panel.

 ![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/2/4/e/24e61d29d5beaac7dc1fd4e9e75979065cde8ee6.png)  
[Panel and slider properties\_getconnected.gh](https://discourse.mcneel.com/uploads/short-url/aVaBJ8WhhOpicGS7rEuBHXX7uaY.gh) (18.4 KB)

---

<div class="post-metadata">

**Author:** ![Intuos](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/intuos/32/771015_2.png) [@Intuos](https://discourse.mcneel.com/u/Intuos)\
**Post date:** [August 13, 2024, 12:09pm UTC](https://discourse.mcneel.com/t/wish-get-panel-and-slider-properties-in-grasshopper/189445/3 "2024-08-13T12:09:54Z")

</div>

That’s exactly the setup I wanted to have/ show, thanks!  
E: Unfortunately this still requires a manual update (or a trigger component) after you change a nickname, so the feature request remains.

---

<div class="post-metadata">

**Author:** ![seltzdesign](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/seltzdesign/32/512215_2.png) [@seltzdesign](https://discourse.mcneel.com/u/seltzdesign)\
**Post date:** [August 13, 2024, 12:18pm UTC](https://discourse.mcneel.com/t/wish-get-panel-and-slider-properties-in-grasshopper/189445/4 "2024-08-13T12:18:30Z")

</div>

Once again, Metahopper has thought of that and gives you an “expire object” component. Just select the object and always set it to true. It will now always update automatically:

![expire](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/8/5/7/857a789e752995f2b5dfa9a212dd39fe97228094.gif)

[Panel and slider properties\_getconnected.gh](https://discourse.mcneel.com/uploads/short-url/iyQemeqUSLfzpfjOBW2SafxiWYA.gh) (24.0 KB)

ps: I noticed that if you leave the expire object toggle on True all the time, it seems like GH doesn’t save properly. Pretty sure this is a bug in Metahopper. Also it will really slow down your definitions, so use with caution.

---

<div class="post-metadata">

**Author:** ![Intuos](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/intuos/32/771015_2.png) [@Intuos](https://discourse.mcneel.com/u/Intuos)\
**Post date:** [August 13, 2024, 12:23pm UTC](https://discourse.mcneel.com/t/wish-get-panel-and-slider-properties-in-grasshopper/189445/5 "2024-08-13T12:23:41Z")

</div>

I’m positive the McNeel team could design a solution that circumvents both problems in the future. 😁

---

<div class="post-metadata">

**Author:** ![seltzdesign](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/seltzdesign/32/512215_2.png) [@seltzdesign](https://discourse.mcneel.com/u/seltzdesign)\
**Post date:** [August 13, 2024, 2:04pm UTC](https://discourse.mcneel.com/t/wish-get-panel-and-slider-properties-in-grasshopper/189445/6 "2024-08-13T14:04:20Z")

</div>

Not sure. The things that Metahopper does are VERY specialised use-cases and I doubt they will ever be part of Grasshopper natively. They are just too “hacky” and you usually just need them for some workaround.

Why do you need the user text to follow the name of the panel? I kind of suspect that you are actually trying to do something that can be solved differently. What is the use-case for this?

---

<div class="post-metadata">

**Author:** ![Intuos](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/intuos/32/771015_2.png) [@Intuos](https://discourse.mcneel.com/u/Intuos)\
**Post date:** [August 13, 2024, 4:18pm UTC](https://discourse.mcneel.com/t/wish-get-panel-and-slider-properties-in-grasshopper/189445/7 "2024-08-13T16:18:05Z")

</div>

It’s reducing the number of names I have to set across the canvas, if the value is already on the slider and the key name as well, why not utilise them? Makes managing them easier.

Take this example (top group), I usually replace sliders with panels whenever I have the slider inputs appear elsewhere (so I can see where the values come from, a parameter, but don’t have the wire clutter). If I could leverage these sliders directly (bottom group), it makes for a more elegant script organisation. And there would be no way to introduce typos since everything references a single source slider.

 ![afbeelding](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/f/3/3/f3368e46135ca8cd19429ae9c421aacaa7953518.png)

---

<div class="post-metadata">

**Author:** ![seltzdesign](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/seltzdesign/32/512215_2.png) [@seltzdesign](https://discourse.mcneel.com/u/seltzdesign)\
**Post date:** [August 13, 2024, 4:33pm UTC](https://discourse.mcneel.com/t/wish-get-panel-and-slider-properties-in-grasshopper/189445/8 "2024-08-13T16:33:10Z")

</div>

Okay, yeah that makes sense. I don’t really use User Key/Values so much, except for where I am storing some information for a script to use, but not for anything else.

Btw, for keeping definitions clean and easy to understand I usually do the following:

1. Create a new slider and name it
2. Create a new parameter and give it the same name
3. I have the Sunglasses plugin set to only show names on Parameters
4. That way you have named parameters
5. Then I place one to the right of the slider
6. Every connection to the definition now goes from the parameter, not the slider
7. Everywhere I need a certain slider value, I copy the named parameter of it and connect those.
8. Same for outputs

That way you will only ever see named parameters going into or out of a section.

It takes a little while longer and I only do this for scripts I know will be updated/developed a lot and/or kept around for a long time.

In the end it looks something like this:

 ![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/8/e/d/8eda13273dd8242b1db3b159bec2b9a8fafc0fcb.jpeg)

So yeah Sunglasses and SnappingGecko really help for clean definitions.

But to come back to your point, yes, I think it would be nice to have a built-in way to set sliders and so as User Keys/Values!

---

<div class="post-metadata">

**Author:** ![martinsiegrist](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/martinsiegrist/32/772775_2.png) [@martinsiegrist](https://discourse.mcneel.com/u/martinsiegrist)\
**Post date:** [August 13, 2024, 4:35pm UTC](https://discourse.mcneel.com/t/wish-get-panel-and-slider-properties-in-grasshopper/189445/9 "2024-08-13T16:35:51Z")

</div>

This topic might be helpful

> [@Populate Value List updated to Python 3](https://discourse.mcneel.com/t/populate-value-list-updated-to-python-3/180201/24):
>
> Oh? That implies the same code will work in IronPython 2? And it does bangbang This version has the same source in both versions, [same as what I linked to](https://discourse.mcneel.com/t/setting-the-entries-in-a-value-list/110781/51), now using isinstance(obj, gh.Kernel.Special.GH\_ValueList) instead of type(obj). [PVL\_2024Apr17a.gh](https://discourse.mcneel.com/uploads/short-url/lIRjM3G6FBXeRYGiLKsIg9TSXbA.gh) (14.7 KB)

---

<div class="post-metadata">

**Author:** ![Intuos](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/intuos/32/771015_2.png) [@Intuos](https://discourse.mcneel.com/u/Intuos)\
**Post date:** [August 13, 2024, 4:50pm UTC](https://discourse.mcneel.com/t/wish-get-panel-and-slider-properties-in-grasshopper/189445/10 "2024-08-13T16:50:32Z")

</div>

> [@seltzdesign](#):
>
> Btw, for keeping definitions clean and easy to understand I usually do the following:
> 
> 1. Create a new slider and name it
> 2. Create a new parameter and give it the same name
> 3. I have the Sunglasses plugin set to only show names on Parameters
> 4. That way you have named parameters
> 5. Then I place one to the right of the slider
> 6. Every connection to the definition now goes from the parameter, not the slider
> 7. Everywhere I need a certain slider value, I copy the named parameter of it and connect those.
> 8. Same for outputs
> 
> That way you will only ever see named parameters going into or out of a section.

I do the same with panels, which I give a red colour for a new parameter and a less saturated red for a parameter value which stems from a slider. I set their wire visibility to invisible and colour the panel using Metahopper. It gives the same result, be it with a coloured panel that I can name and spot more easily than a parameter.

---

<div class="post-metadata">

**Author:** ![AndersDeleuran](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/andersdeleuran/32/476683_2.png) [@AndersDeleuran](https://discourse.mcneel.com/u/AndersDeleuran)\
**Post date:** [August 14, 2024, 9:03am UTC](https://discourse.mcneel.com/t/wish-get-panel-and-slider-properties-in-grasshopper/189445/11 "2024-08-14T09:03:51Z")

</div>

> [@Intuos](#):
>
> I would like to see two components that can read the properties of panels and sliders. That way, you can use the (nick)name of a panel/ slider and their values as Keys and Values respectively. Metahopper has a component that works for sliders, however, you cannot directly feed in the slider…

One can probably script that fairly trivially, until a “more” native solution appears:

 ![2024-08-14 10_56_07-Grasshopper - 240814_GetCanvasObjectProperties_00](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/e/1/f/e1f79c6c8d9831f8aa2f00077c5e5ac6b87d14ea.png)  
[240814\_GetCanvasObjectProperties\_00.gh](https://discourse.mcneel.com/uploads/short-url/56NCcIuYOIEVZOOzwnyKWB3Gp2v.gh) (7.3 KB)

> [@Intuos](#):
>
> … nor does in expire when the slider’s name is changed

Changing the nick name of canvas objects does not appear to expire downstream components. I wonder if that’s by design. Either way, I’m not entirely sure how one would add that to the scripts above (e.g. they would have to listen to changes). But it might be equally trivial.

---

<div class="post-metadata">

**Author:** ![martinsiegrist](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/martinsiegrist/32/772775_2.png) [@martinsiegrist](https://discourse.mcneel.com/u/martinsiegrist)\
**Post date:** [August 14, 2024, 9:10am UTC](https://discourse.mcneel.com/t/wish-get-panel-and-slider-properties-in-grasshopper/189445/12 "2024-08-14T09:10:12Z")

</div>

Why does this fail to output a result in a python 3 script component?

 ![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/d/f/4/df45312b3e9732bacdce682404e04f0f84e46742.png)

[240814\_GetCanvasObjectProperties\_00\_python-3-fail.gh](https://discourse.mcneel.com/uploads/short-url/teQneKDlrK2cC9EFJPWAxGakztD.gh) (12.5 KB)

---

<div class="post-metadata">

**Author:** ![AndersDeleuran](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/andersdeleuran/32/476683_2.png) [@AndersDeleuran](https://discourse.mcneel.com/u/AndersDeleuran)\
**Post date:** [August 14, 2024, 9:16am UTC](https://discourse.mcneel.com/t/wish-get-panel-and-slider-properties-in-grasshopper/189445/13 "2024-08-14T09:16:24Z")

</div>

> [@martinsiegrist](#):
>
> Why does this fail to output a result in a python 3 script component?

I don’t know (still not using Rhino 8). Try uploading the file and maybe someone can have a look. **Edit:** From memory seeing issues being reported here on Discourse, I bet it’s the `type(obj)` check on line 9 that isn’t returning the correct type (i.e. `GH_NumberSlider`). Generally speaking, I wouldn’t recommend using CPython for all this meta programming stuff, or for interop with .NET in general (i.e. due to type issues). At least use IronPython, or better yet (if your goal is predictability and performance), stick with GhPython for now.

---

<div class="post-metadata">

**Author:** ![martinsiegrist](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/martinsiegrist/32/772775_2.png) [@martinsiegrist](https://discourse.mcneel.com/u/martinsiegrist)\
**Post date:** [August 14, 2024, 9:37am UTC](https://discourse.mcneel.com/t/wish-get-panel-and-slider-properties-in-grasshopper/189445/14 "2024-08-14T09:37:36Z")

</div>

Ok, thanks for the information. It works with IronPython. My brain doesn’t like the ‘OLD’ tag on the python components… 😆

---

<div class="post-metadata">

**Author:** ![AndersDeleuran](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/andersdeleuran/32/476683_2.png) [@AndersDeleuran](https://discourse.mcneel.com/u/AndersDeleuran)\
**Post date:** [August 14, 2024, 9:42am UTC](https://discourse.mcneel.com/t/wish-get-panel-and-slider-properties-in-grasshopper/189445/15 "2024-08-14T09:42:28Z")

</div>

> [@martinsiegrist](#):
>
> My brain doesn’t like the ‘OLD’ tag on the python components… 😆

Hehe, me neither, so rude… I usually un-check this one:

 ![2024-08-14 11_39_16-C__Deleuran_Projects_Huguet_01_InitialCoding_240814_InitialCoding_00.3dm (65 KB)](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/c/e/1/ce175e889ed2ec0c956affc31aca250bb0b6dcf6.png)

---

<div class="post-metadata">

**Author:** ![Adam\_M](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/adam_m/32/769331_2.png) [@Adam\_M](https://discourse.mcneel.com/u/Adam_M)\
**Post date:** [August 14, 2024, 9:48am UTC](https://discourse.mcneel.com/t/wish-get-panel-and-slider-properties-in-grasshopper/189445/16 "2024-08-14T09:48:10Z")

</div>

FYI: The type shows as Grasshopper.Kernel.IGH\_Param

---

<div class="post-metadata">

**Author:** ![Intuos](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/intuos/32/771015_2.png) [@Intuos](https://discourse.mcneel.com/u/Intuos)\
**Post date:** [August 14, 2024, 2:12pm UTC](https://discourse.mcneel.com/t/wish-get-panel-and-slider-properties-in-grasshopper/189445/17 "2024-08-14T14:12:15Z")

</div>

Is it possible to make the component function like a merge component with (+) and (-) buttons to add/ remove inputs when you zoom in? That would allow me to rearrange them.

---

<div class="post-metadata">

**Author:** ![AndersDeleuran](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/andersdeleuran/32/476683_2.png) [@AndersDeleuran](https://discourse.mcneel.com/u/AndersDeleuran)\
**Post date:** [August 14, 2024, 2:38pm UTC](https://discourse.mcneel.com/t/wish-get-panel-and-slider-properties-in-grasshopper/189445/18 "2024-08-14T14:38:02Z")

</div>

> [@Intuos](#):
>
> Is it possible to make the component function like a merge component with (+) and (-) buttons to add/ remove inputs when you zoom in?

It is, but not trivially so. Especially with a scripting component.

> [@Intuos](#):
>
> That would allow me to rearrange them.

You can edit this within the script, which _is_ very trivial (i.e. reorder the comma separated items on line 11).

**Edit:** Sorry I think I misunderstood. We can also iterate the inputs parameters. And since GhPython is already a ZUI component, this is in fact also a pretty trivial edit:

 ![2024-08-14 17_17_42-Wish_ Get panel and slider properties in Grasshopper - Serengeti (Rhino WIP) - M](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/3/f/7/3f72fc9cdbbe4f4491f037e1b767665156ba44e4.png)  
[240814\_GetCanvasObjectProperties\_01.gh](https://discourse.mcneel.com/uploads/short-url/vYpvIH7UmrsTyGCIySHmYGCRTpA.gh) (8.9 KB)

---

<div class="post-metadata">

**Author:** ![Intuos](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/intuos/32/771015_2.png) [@Intuos](https://discourse.mcneel.com/u/Intuos)\
**Post date:** [August 15, 2024, 9:00am UTC](https://discourse.mcneel.com/t/wish-get-panel-and-slider-properties-in-grasshopper/189445/19 "2024-08-15T09:00:05Z")

</div>

Something else I noticed with Metahopper’s components is that they aren’t really suited to create trees from lists.

 ![afbeelding](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/e/1/5/e15d328d67a54760df85203f1cf1d6bd0fd75194.png)

Notice the items are all merged under a single index at the end.

E: Also, the script doesn’t function with multiline data panels yet:

 ![afbeelding](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/1/5/4/1543b1fbc7503985c2519420afe502b94da9fc39.png)

E2: Ideally, I’d like to have something like this where the first item can be matched with a geometry attribute and the other values can be used by the script:

 ![afbeelding](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/d/9/f/d9f4573f21996d3002f0e39b2798689f4024812e.png)

---

<div class="post-metadata">

**Author:** ![martinsiegrist](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/martinsiegrist/32/772775_2.png) [@martinsiegrist](https://discourse.mcneel.com/u/martinsiegrist)\
**Post date:** [December 31, 2025, 12:27pm UTC](https://discourse.mcneel.com/t/wish-get-panel-and-slider-properties-in-grasshopper/189445/20 "2025-12-31T12:27:24Z")

</div>

It works now 🙂

[canvas\_object\_properties\_python.gh](https://discourse.mcneel.com/uploads/short-url/fO3lNSSwqOOHoZT3eu2PUgeeeiO.gh) (15.6 KB)

```auto
import Grasshopper.Kernel.Special as ghs
from ghpythonlib import treehelpers as th

properties = []

# Make sure there is at least one input param
inputs = ghenv.Component.Params.Input
if len(inputs) > 0:
    for src in inputs[0].Sources:
        # Use isinstance, more robust than type(...) is ...
        if isinstance(src, ghs.GH_NumberSlider):
            sl = src.Slider

            # In most Rhino 8 builds these are still properties.
            # If you get an AttributeError, see section 2 below.
            name = src.NickName
            val = sl.Value
            mn = sl.Minimum
            mx = sl.Maximum

            properties.append((name, val, mn, mx))

Properties = th.list_to_tree(properties)

```
