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.
Here’s one approach, using GHPython and targeting a named value list:
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.
Update: The Object Info component doesn’t seem to work inside a cluster. That’s a shame.
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.
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…
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.
Oh, yeah, that makes sense!
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.
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.
You can do by explicitly wrapping your string in string quotes, like so:
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.
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.
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.
Yes, that also seems like a good idea, but since my keys are dynamic (folder contents) I’d rather keep it completely manual.
I still think all the value-setting shenanigans are way overkill
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?
Yes, that is the Item Selector component from the Human plugin.
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)
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?