Hi guys, sorry if this sounds a little convoluted, I’m trying to use multi-layered list loop,
To turn this:
[[1, 11, 111, 1111], [2, 22, 222, 2222], [3, 33, 333, 3333], [4, 44, 444, 4444], [5, 55, 555, 5555], [6, 66 , 666, 6666]];
into this:
[[1,11,1111], [11,111,1111], [2,22,2222], [22, 222,2222]…[6,66,6666], [66, 666, 6666]]
Basically taking the original 6 list of 4 items, and rearranging them in a specific order into a 12 list of 3 items each
This is the same logic one would use when turning a quad point division into a triangle division, I want to learn how to do it in Python
Here’s my attempt:
# Load the Python Standard and DesignScript Libraries
import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
from operator import *
# The inputs to this node will be stored as a list in the IN variables.
listA = IN[0]
# Place your code below this line
overallList = []
for i in range(5):
sublist1 = []
sublist2 = []
sublist3 = []
sublist4 = []
sublist5 = []
sublist6 = []
for i2 in range(1):
sublist1.append(listA[i2][0])
sublist1.append(listA[i2][1])
sublist1.append(listA[i2][3])
sublist2.append(listA[i2][1])
sublist2.append(listA[i2][2])
sublist2.append(listA[i2][3])
for i2 in range(1,2):
sublist3.append(listA[i2][0])
sublist3.append(listA[i2][1])
sublist3.append(listA[i2][3])
sublist4.append(listA[i2][1])
sublist4.append(listA[i2][2])
sublist4.append(listA[i2][3])
for i2 in range(2,3):
sublist5.append(listA[i2][0])
sublist5.append(listA[i2][1])
sublist5.append(listA[i2][3])
sublist6.append(listA[i2][1])
sublist6.append(listA[i2][2])
sublist6.append(listA[i2][3])
overallList.append(sublist1)
overallList.append(sublist2)
overallList.append(sublist3)
overallList.append(sublist4)
overallList.append(sublist5)
overallList.append(sublist6)
# Assign your output to the OUT variable.
OUT = overallList
There has to be a easier and more elegant solution than what I have.