Quantcast
Channel: Scripting - McNeel Forum
Viewing all articles
Browse latest Browse all 5890

Weave lists of pts together

$
0
0

@brobes05 wrote:

I am new to python (sort of), anyway I am not sure why this is not working. Should be simple to weave two lists together with a boolean pattern of true false.

I don't really understand how to flatten the two lists after using python's built in 'zip' function.

import rhinoscriptsyntax as rs

list1 = []
list2 = []
list3 = []


for x in range (0,20,2):
    y = 0
    z = 0
    ptlist1 = rs.AddPoint(x,y,z)
    list1.append(ptlist1)
    
    for x2 in range (0,20,3):
        y = 0
        z = 0
        ptlist2 = rs.AddPoint(x2,y,z)
        ptlist2move = rs.MoveObjects(ptlist2, (0,5,0))
#        rs.DeleteObjects(ptlist2)
        list2.append(ptlist2move)
        
def weaveLists():
    zip(list1, list2)
    flattenList = [item for sublist in zip(list1, list2) for item in sublist] #this line confuses me
    list3.append(flattenList)
    return rs.AddPolyline(list3)
    
# attempting to weave lists together with a boolean pattern like the 'weave' pattern in 
# grasshopper.

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 5890

Trending Articles