Runtime error (MissingMemberException): ‘type’ object has no attribute ‘__index__’
Traceback:
line 32, in list_to_tree, […]
I’m not really sure why this comes up. Maybe @DavidRutten knows something?
Or somebody else ever had this error?
Using output = nestedList does “work” (you’ll get “IronPython.Runtime.List” of course). output = nestedList[0] also works fine, you get what you’d expect.
Thanks for your answer, Chris!
Sadly it doesn’t seem to help, tho.
There are too many LoC, but stripped down it’s basically like this:
class MyAgent():
# init ....
#
def make_some_geom(self):
# make some geometry here
nestedList[self.ID].append(someGeom)
if "agentsList" not in globals():
agentsList = []
nestedList = [[] for i in range(nAgents)] # make empty (sub-)lists so I can append later
#... init the agents here with ID
if RUN: # run is a bool toggle
for agent in agentsList:
# of course there is actually more here and not this function call directly
agent.make_some_geom()
ghenv.Component.ExpireSolution(True) # instead of the timer component
# output
output = nestedList #....
@piac might be able to offer some further insight. I would guess it’s your nested list structure…
maybe this sample helps? (dummy example to show a basic nested list structure).
import ghpythonlib.treehelpers as th
uPts = []
# reparameterize input surface
S.SetDomain(0, Rhino.Geometry.Interval(0,1))
S.SetDomain(1, Rhino.Geometry.Interval(0,1))
# create columns of points on surface
# using a nested list will allow conversion to datatree
for i in range(0, U):
newColumn = []
for j in range(0, V):
newColumn.append(S.PointAt(i * (1 / (U - 1)), j * (1 / (V - 1))))
uPts.append(newColumn)
a = th.list_to_tree(uPts, True)