algorithmic modeling for Rhino
Tags:
On a related note, I'm trying to use the GH_Pth.Indices property to convert a data tree into a nested list in python. When I run the code and print the list:
pathvalues = []
for path in treepathlist:
pathvalues.append(path.Indices)
I get:
print pathvalues
[Array[int]((0, 1)), Array[int]((0, 3)), Array[int]((0, 5)), etc . . . .
I tried adding the array module "import Array" and added the code:
for path in treepathlist:
myarray = (path.Indices)
mylist = array.tolist(myarray)
I got the error Runtime error (ArgumentTypeException): expected array, got Array[int]
What is the Array[int] object How can I convert it to the more pythonic list?
Thanks!
I found a solution here: Data Tree Discussion
the code below works:
for path in treepathlist:
patharray = (path.Indices)
myList = [item for item in patharray]
pathvalues.append(myList)
Curious to know what it is doing through, and why this would work.
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by