Python Looping Through List

Hi, this is a fairly basic python question but I’m trying to get my code to select all of the curves stored in a list and I’m getting this error message: “Message: iteration over non-sequence of type Guid”

Here’s the part of the code that’s not working. Any ideas?

def treePath(curve):
    divisions = rs.DivideCurveLength(curve, 10)

    for pt in divisions:
        rs.AddPoint(pt)
        baseRadius = random.uniform(1,3)
        x = pt[0]
        y = pt[1]
        z = random.uniform(.2,3)

        pt2 = [x,y,z]
        radius = random.uniform(.1,.10)
        treeList = []
        circle = rs.AddCircle(pt2, radius)
        baseCircle = rs.AddCircle(pt, baseRadius)
        treeList.append(circle)
        treeList.append(baseCircle)
        rs.AddLoftSrf(treeList)

def mainTwo():
    #add tree path lines
    treeLineList = []
    treeLine1 = rs.AddLine((5,30,0),(90,30,0))
    treeLine2 = rs.AddLine((5,60,0),(90,60,0))
    treeLine3 = rs.AddLine((5,90,0),(90,90,0))
    treeLineList.append(treeLine1)
    treeLineList.append(treeLine2)
    treeLineList.append(treeLine3)
    for i in range(len(treeLineList)):
        myCurves2 = treeLineList[i]

    for curve in myCurves2:
        treePath(curve)

mainTwo()

When you get that message, it’s because what you think is a list… isn’t. It’s a single item, and thus you can’t iterate over it.

for i in range(len(treeLineList)):
    myCurves2 = treeLineList[i]

for curve in myCurves2:
    treePath(curve)

You are successively redefining myCurves2, so in the end it’s still just one item. I guess you would need to do this instead:

myCurves2=[]
for i in range(len(treeLineList)):
    myCurves2.append(treeLineList[i])

for curve in myCurves2:
    treePath(curve)

But I’m not sure why you are creating the list myCurves2, it’s just a copy of treeLineList…

Thanks for the feedback! So what I’m trying to do is for the ‘def treePath’ function I’m trying to loop through the list of lines (treeLineList) so that the function is applied to each line. The only other way that I know will make it work is to use rs.GetObjects and then have the user select the lines. But I’m hoping to automate it so that the code selects all of the lines and applies the function to each. Does that make sense?