algorithmic modeling for Rhino
Hi guys,
i'm quite new at Python scripting, asking your help.
I've got a loop in a loop (two consecutive "for" loop).
Is there a way to create a two dimensional list (whose number of item (list) is the count of the first loop variable).
I'm thinking to something like
list = [list1,list2,list3,...,listN] #where N is the number of cicle in the first loop
list1 is the result of cicle in the second loop (caused by the second variable), like list 2m list3, and so on till to listN..
I've tried like this, but it doesn't work:
MainList = []
SubList = []
for i in range(len(InputList_1)):
MainList.append(SubList)
for j in range(len(InputList_2)):
MainList[i].append(rs.TransformObject(InputList_1[i],XformMatrix[j]))
it retrieves this error:
Runtime error (ArgumentTypeException): __getitem__() takes exactly 2 arguments (1 given)
Tags:
The concept is to create in grasshopper one branch each sublist, but avoiding gh data structure, and creating it in python.
Do you mean making a nested list using two for for loops? If so you can try something like this..
It's almost like that.
I've updated the code, and it works now, but not at all.
It creates too much lists.
This is the code
MainList = []
SubList = []
for i in range(len(InputList_1)):
for j in range(len(InputList_2)):
SubList.append(rs.TransformObject(InputList_1[i],MirrorMatrix_L[j],True))
MainList.append(SubList)
I've just culled the [i] from the last .append
The real problem is that it copies the both the two list j times. Here is a screenshot
2 Different Lists (in different branch) 6 times, for totally 12 branches.
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