# Setting the entries in a value list?

**URL:** <https://discourse.mcneel.com/t/setting-the-entries-in-a-value-list/110781>\
**Category:** metahopper\
**Created:** [October 22, 2020, 9:46am UTC](https://discourse.mcneel.com/t/setting-the-entries-in-a-value-list/110781 "2020-10-22T09:46:20Z")\
**Posts on this page:** 20\
**Page:** 1

<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:** [October 22, 2020, 9:46am UTC](https://discourse.mcneel.com/t/setting-the-entries-in-a-value-list/110781/1 "2020-10-22T09:46:20Z")

</div>

Is it possible to set the values of a value list (dropdown)? Since the edit window is just a text field I think it should be fairly easy to get Metahopper to edit the value list on the fly.

Is this possible already? I can’t find a way to do that right now.

---

<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:** [October 22, 2020, 9:52am UTC](https://discourse.mcneel.com/t/setting-the-entries-in-a-value-list/110781/2 "2020-10-22T09:52:19Z")

</div>

Here’s one approach, using GHPython and targeting a named value list:

 ![2020-09-23 15_41_52-Grasshopper - 200923_PopulateValueList_00](https://global.discourse-cdn.com/mcneel/uploads/default/original/3X/1/a/1a0526f70104f7809c050ad2df2bba015b7af328.png)  
[200923\_PopulateValueList\_00.gh](https://discourse.mcneel.com/uploads/short-url/hKWYK3tbYTX6FcBq278AeLiGabr.gh) (7.9 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:** [October 22, 2020, 10:01am UTC](https://discourse.mcneel.com/t/setting-the-entries-in-a-value-list/110781/3 "2020-10-22T10:01:24Z")

</div>

Amazing, thanks!

I turned it into a cluster, added a Metahopper component to get the nickname automatically and saved it as a user object in the MetaHopper category, so I can find it where I would expect it.

 ![set value list](https://global.discourse-cdn.com/mcneel/uploads/default/original/3X/7/4/74c1ceebefde4be414213bdd4eda3bdb3cf5ec12.jpeg)

---

<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:** [October 22, 2020, 10:07am UTC](https://discourse.mcneel.com/t/setting-the-entries-in-a-value-list/110781/4 "2020-10-22T10:07:27Z")

</div>

Update: The Object Info component doesn’t seem to work inside a cluster. That’s a shame.

---

<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:** [October 22, 2020, 10:08am UTC](https://discourse.mcneel.com/t/setting-the-entries-in-a-value-list/110781/5 "2020-10-22T10:08:40Z")

</div>

I’m actually surprised that it would work within a cluster. Being that a cluster is a Grasshopper document within a parent Grasshopper document (or something to that effect).

**Edit:** What you said 😉  
**Edit II:** You can make a GHPython component into a user object directly without clustering it, and it should work as expected.

---

<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:** [October 22, 2020, 12:02pm UTC](https://discourse.mcneel.com/t/setting-the-entries-in-a-value-list/110781/6 "2020-10-22T12:02:56Z")

</div>

Well, its working great. Now I just realise and wish a Value List could have strings as values. If I am selecting something I dont always need to output a number, but sometimes a string, like a file or layer path or even any other data type. Oh well…

---

<div class="post-metadata">

**Author:** ![andheum](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/andheum/32/743341_2.png) [@andheum](https://discourse.mcneel.com/u/andheum)\
**Post date:** [October 22, 2020, 12:09pm UTC](https://discourse.mcneel.com/t/setting-the-entries-in-a-value-list/110781/7 "2020-10-22T12:09:00Z")

</div>

It’s not that object info doesn’t work inside a cluster, it’s that “Get connected objects” doesn’t work inside a cluster. the object it’s connected to is the cluster input, not the object outside the cluster.

---

<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:** [October 22, 2020, 12:09pm UTC](https://discourse.mcneel.com/t/setting-the-entries-in-a-value-list/110781/8 "2020-10-22T12:09:37Z")

</div>

Oh, yeah, that makes sense!

---

<div class="post-metadata">

**Author:** ![andheum](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/andheum/32/743341_2.png) [@andheum](https://discourse.mcneel.com/u/andheum)\
**Post date:** [October 22, 2020, 12:16pm UTC](https://discourse.mcneel.com/t/setting-the-entries-in-a-value-list/110781/9 "2020-10-22T12:16:17Z")

</div>

Also, I don’t know if this helps in your case, but the “item selector” from Human is nothing more than a Value List that takes a list input — so you can provide it with a changing set of items that a user can pick from. But maybe you need a value list specifically in this case.

---

<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:** [October 22, 2020, 12:18pm UTC](https://discourse.mcneel.com/t/setting-the-entries-in-a-value-list/110781/10 "2020-10-22T12:18:44Z")

</div>

Yes, I have used it a few times and love it. In this case I need the key value pair though, since I want to have nice names in the dropdowns. So now I just assign integers to the choices and then pick the actual data elsewhere (file paths) - they would be too long for the dropdown.

---

<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:** [October 22, 2020, 12:30pm UTC](https://discourse.mcneel.com/t/setting-the-entries-in-a-value-list/110781/11 "2020-10-22T12:30:39Z")

</div>

> [@seltzdesign](#):
>
> Now I just realise and wish a Value List could have strings as values.

You can do by explicitly wrapping your string in string quotes, like so:

 ![2020-10-22 14_25_31-Grasshopper - 201022_PopulateValueList_00](https://global.discourse-cdn.com/mcneel/uploads/default/original/3X/4/3/43550cd6703502d56e830fe6fa76f1cc180ec5ad.png)  
[201022\_PopulateValueList\_00.gh](https://discourse.mcneel.com/uploads/short-url/yKBJumLNbCiWC7cIKZAaDPhSV7y.gh) (4.4 KB)

That’s getting a bit finicky, and I’m sure there are probably simpler solutions. One should probably at least check the type of the value, and then go into a conditional based on integer, float, or string.

---

<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:** [October 22, 2020, 12:48pm UTC](https://discourse.mcneel.com/t/setting-the-entries-in-a-value-list/110781/12 "2020-10-22T12:48:33Z")

</div>

I just noticed that there needs to be a Set input so it doesn’t set the options on every calculation. Otherwise on every recalculation it resets the selected choice in the dropdown, at least if you are setting multiple dropdowns as in my case.

 ![set value list bool](https://global.discourse-cdn.com/mcneel/uploads/default/original/3X/3/5/3589bd61837e83068a6875256b662afdfc0d23d3.jpeg)

---

<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:** [October 22, 2020, 1:21pm UTC](https://discourse.mcneel.com/t/setting-the-entries-in-a-value-list/110781/13 "2020-10-22T13:21:13Z")

</div>

Indeed, my example will just compute whenever the component is triggered. I’d probably add a check, that first compares the current key/values to the new input key/values, and then only proceed to edit the value list if those aren’t the same.

---

<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:** [October 22, 2020, 1:22pm UTC](https://discourse.mcneel.com/t/setting-the-entries-in-a-value-list/110781/14 "2020-10-22T13:22:46Z")

</div>

Yes, that also seems like a good idea, but since my keys are dynamic (folder contents) I’d rather keep it completely manual.

---

<div class="post-metadata">

**Author:** ![andheum](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/andheum/32/743341_2.png) [@andheum](https://discourse.mcneel.com/u/andheum)\
**Post date:** [October 23, 2020, 11:28am UTC](https://discourse.mcneel.com/t/setting-the-entries-in-a-value-list/110781/15 "2020-10-23T11:28:55Z")

</div>

I still think all the value-setting shenanigans are way overkill 🙂

 ![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/3X/8/c/8ce7e67ab24d1206804f4370318044d8ad05e13b.png)

---

<div class="post-metadata">

**Author:** ![ruud.vanknippenberg](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/ruud.vanknippenberg/32/660928_2.png) [@ruud.vanknippenberg](https://discourse.mcneel.com/u/ruud.vanknippenberg)\
**Post date:** [January 7, 2021, 1:51pm UTC](https://discourse.mcneel.com/t/setting-the-entries-in-a-value-list/110781/16 "2021-01-07T13:51:49Z")

</div>

Hi!

Ahh looks great!  
But how do you get a (dropdown) value list with an input?

If I add a value list I dont have an input… What do you fill-in at the value list constants?  
Or is it another component?

Thanks again! 🙂

 ![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/7/0/a/70adb5b5e704eff0ee1c002793ce61b5bfc57251.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:** [January 7, 2021, 1:54pm UTC](https://discourse.mcneel.com/t/setting-the-entries-in-a-value-list/110781/17 "2021-01-07T13:54:45Z")

</div>

Yes, that is the Item Selector component from the [Human](https://www.food4rhino.com/app/human) plugin.

 ![item_selector](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/5/f/c/5fce188f6f26ee21743bdd909814b139ee41b2e2.jpeg)

---

<div class="post-metadata">

**Author:** ![ruud.vanknippenberg](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/ruud.vanknippenberg/32/660928_2.png) [@ruud.vanknippenberg](https://discourse.mcneel.com/u/ruud.vanknippenberg)\
**Post date:** [January 7, 2021, 1:58pm UTC](https://discourse.mcneel.com/t/setting-the-entries-in-a-value-list/110781/18 "2021-01-07T13:58:53Z")

</div>

Ahh oke thanks!

that works for me thanks.  
The only thing is that everyone who is going to use my script has to have the human plugin…

So I think you previous solution is better. I alsonoticed that it resets all the values when it is 'recalculated. Would it be possible to send the updated component? (I am not an python expert)

thanks again:)

---

<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:** [January 7, 2021, 2:17pm UTC](https://discourse.mcneel.com/t/setting-the-entries-in-a-value-list/110781/19 "2021-01-07T14:17:46Z")

</div>

Sure, here you go:

 ![set_dropdown](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/e/8/c/e8c9bd1bfde893f54ad82e8e83b2eb7ad82ae13c.jpeg)

[set\_dropdown.gh](https://discourse.mcneel.com/uploads/short-url/qJaHwHHLfUkF8ngUhiPai4uuwVE.gh) (6.7 KB)

---

<div class="post-metadata">

**Author:** ![ruud.vanknippenberg](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/ruud.vanknippenberg/32/660928_2.png) [@ruud.vanknippenberg](https://discourse.mcneel.com/u/ruud.vanknippenberg)\
**Post date:** [January 7, 2021, 2:28pm UTC](https://discourse.mcneel.com/t/setting-the-entries-in-a-value-list/110781/20 "2021-01-07T14:28:02Z")

</div>

Ahh thanks!

sorry but, 1 more question, would it also be possible to return a non-value / text?

So you select a name, and that name is also the output?

Thanks again 🙂

 ![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/0/5/3/05375522357037f9e903557ea7de4dbac99f6b4c.png)

[Next page](https://discourse.mcneel.com/t/setting-the-entries-in-a-value-list/110781.md?page=2)
