Setting the entries in a value list?

Boo Hoo. :cry: I just tried your old reliable PVL (PopulateValueList) Python component using R7 and it fails with the following error:

Runtime error (MissingMemberException): 'NoneType' object has no attribute 'Name'

Traceback:
  line 25, in script

What happened? This was really useful, and simple. Any help please :question:

"""
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_2024Jan1a
PVL_2024Jan1a.gh (13.9 KB)

1 Like