Iterate through list

Im trying to iterate though this list I have created, however it only returns a single value. Theres something wrong with the iteration but dont know what

Hi @technitutors ,

You almost never need to use the LoopWhile node in Dynamo, what are you trying to achieve?

the python input can only take one element at a time. So an option is to recode the python to run through the list or something similar. Ive looked through how to run a loop with a list but not coming up with any results

You would have to use a For loop in your Python script.

See something like this, or search for “For Loop”:

do you know the exact syntax? Ive tried this but still giving errors

Hi,

Since @Daan linked to my post I thought I’d chip in.

I can’t test this right now, but it looks pretty straight forward.
Something like this:

for x in rebar:
    x.SetPresentationMode(myview, RebarPresentationMode.Middle)
    output.append(x)

OUT =  output

I dont think the output here is really needed, as it will just return the rebar elements. Could probably do something smarter :slight_smile:

2 Likes

thanks guys, its just the syntax I was looking for which I didnt quite fit. It works well now

1 Like