"""
Populate Value List
Inputs:
Name: {item,str}
Keys: {list,str}
Values: {list,str}
Outputs:
Remarks:
Author: Anders Holden Deleuran (BIG IDEAS)
Rhino: 6.30.20266.14531
Version: 210108
"""
ghenv.Component.Name = "PopulateValueList"
ghenv.Component.NickName = "PVL"
import Grasshopper as gh
if not Values:
Values = Keys
if Keys and Values:
for obj in ghenv.Component.OnPingDocument().Objects:
if type(obj) is gh.Kernel.Special.GH_ValueList:
if obj.NickName == Name:
selected = obj.FirstSelectedItem.Name
obj.ListItems.Clear()
for k,v in zip(Keys,Values):
vli = gh.Kernel.Special.GH_ValueListItem(str(k),str('"' + v + '"'))
obj.ListItems.Add(vli)
if selected in Keys:
obj.SelectItem(Keys.index(selected))
obj.ExpireSolution(True)
PVL_2023Mar19a.gh (8.6 KB)