I’ve seen that Ladybug and Honeybee make use of the Value List as a shortcut for calling and loading templates in Grasshopper. How do I go about doing something similar, but where the values in the list are generated from a backend storage space like scriptcontext’s sticky dictionary or something similar?
The top one is the Value List as used by Honeybee/Ladybug, the lower one is how my customized Values List with theoretically look like. What I’d like to do is that the Values List can load a list of values available from an external storage space like sc.sticky, and that it will immediately change its available values if this storage space is added to or subtracted from. Is it also possible to have outputs other than integer/float values, i.e. strings?
I don’t need to stick to using Value List, the gist is that I’d like to generated a drop-down menu “component” in Grasshopper, using Python. Any hints or alternatives approaches would be much appreciated, thanks!
I think it is dangerous. If you are running your python in a ghPython component, which means your code will run during an active solution. During that, it is really a bad thing to manipulate any other component (so usually the dirty job is done in AfterSolveInstance routine, which I’m unsure if ghPython supports).
Sorry, I’m not so familiar with Python in GH. I would say it is the same approach as you from Grasshopper.Kernel.Special import GH_ValueList, GH_ValueListItem (pseudo-code, i don’t know if it works)
First create a list of GH_ValueListItem and insert them into GH_ValueList.ListItems. The rest of code is to ensure
Previous selection is not lost if the list before and after share same elements
The component is correctly expired and placed, as its size may change