Why not use two item selectors? I actually find that if I plug in all 1384 names my GH freezes for like 30 seconds and it would be a way too long list to scroll.
I would use 2 selectors and remove the “All” category first, since that would mean in the names list you have everything twice, since All contains all the others anyways.
I’ve just created a GH model that displays ALL the polyhedra by branch in a grid. Very cool to see them. I think my favorite is the “Rhombic Icosahedron ” which has 20 equal size diamond shaped faces. It is [index = 15] in category “Other Solids” [index = 17].
Boo Hoo. 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
"""
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)
Which file would that be? I know how it’s supposed to work as I’ve been using it for years, so the video is no help. As I reported three days ago, it doesn’t work anymore.
Solution exception:‘NoneType’ object has no attribute ‘Name’
Solution exception:unsupported operand type(s) for +: ‘str’ and ‘float’
The file name is in the top left corner of the Grasshopper window in the recording. It’s the second one here.
I’m not sure what to tell you, I just ran my latest file (i.e. 210108_PopulateValueList_02.gh) with the latest Rhino 7 update (i.e. in the video I just posted) and it seemed to work
Edit: I just saw your post above, and it looks like you’re using two PVL components hooked up to the same inputs, one of which has no Values input. These conditions combined will likely cause all sorts of time-sequence issues.
This version of @AndersDeleuran’s PVL(PopulateValueList) Python component has changes to fix a few anomalies I encountered:
Added code to accept only Keys. If no Values are are connected they will default to the Keys.
if not Values:
Values = Keys
Added Type hint = ‘str’ (String) to all three inputs, making it possible to use integers without error.
Handle empty Value Lists by changing this: selected = obj.FirstSelectedItem.Name
to this: selected = obj.FirstSelectedItem
"""
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
misc. debugs by Joseph Oster, Jan 4, 2024
"""
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
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)
I’m just gonna quite myself from three years ago here:
… but specifically to your points:
I’d argue this is “anomalous” behavior, unless documented of course. If one wants the keys to be also be the values, one can wire the input data to both inputs.
The component docstring explicitly states that the Keys and Values are both lists of strings. But I’d agree that is limiting. I think we might have covered this above or elsewhere if I recall. Anywho, one can change line 29 to format the value like so (i.e. check if the value is an integer or a number):
This way one can pass strings, floats or integers. And that’s actually what they will become inside the value list (i.e. numbers aren’t just strings with quotation marks). Note that integers might (i.e. depending on their origin) have to be explicitly cast using an integer component or by applying typehints.
I’m afraid I haven’t been able to reproduce this issue.
In all cases, the changes I made were because I hit obstacles in the course of normal use, including empty Value Lists. You can create one by editing its contents and deleting all, but that’s not how it happened. Other errors (integers instead of strings) caused them to become empty, but it doesn’t matter how they became empty, the code didn’t handle the condition and recover, as it does now.
I fixed conditions that broke the code so badly that extraordinary steps were required to recover. In my experience, those are nasty bugs that can be avoided by prudent programming.
It sounds to me like you are writing from a theoretical, academic point of view rather than a practical one. My career as a programmer was always for real people trying to get something done. “Blocker bugs” were always unacceptable and they still are. I posted code three days ago that demonstrated these bugs, which IMHO is far better than any video, but you apparently ignored that.
Hey Guys!
I hope this help. I arrived at this thread looking into solving a related issue and thanks to @AndersDeleuran and @Joseph_Oster back and forth, solved my own.
I was looking for a component that, when triggered, would automatically produce a “valueList” “Checklist” with a number of items given an int input.