Code Block - Troubles with overwriting variable in loop

Hi guys!

I’m pretty new to writing code blocks in dynamo and I’ve really come to a dead end with what I’m trying to do. Basically I just want to create a for loop where a polycurve is being modified by a custom node that I have created for each iteration. Everything works fine except that I cannot overwrite the previous version of the polycurve in the new iteration. The result that I get makes sense if it was always the original polycurve that was being imputed to the function. My guess is that it has something to do with the scope of the variables, but i haven’t been able to figure out how to work around it.

I experimented a bit to make the problem more clear and with less variables. In the left picture, I would like to find a way to overwrite b without causing an error (i thing this is what the whole thing boils down to).

Thank you so much!

you can overwrite variables inside an imperative block only. So try using that in your smaller example as well.

ind = [1..itts] will yield a nested list, did you want that? [[1,2,3]]

1 Like

Hi Michael!

Thank you so much for your reply! This was indeed the problem. I thought I would get a flat list of ints by doing that, but by having the hard brackets I got a nested list just as you said. So hard when you can’t really debug. Anyway, thanks a lot for the help!

The only trouble I have left now is that I would like to add a number of Curves to the list “recs” in the code for each loop and I can’t really figure out how to do that either. I’ve tried recs.Append(“function that returns Curves”), bur I just get a null result from this. Do you have a quick fix for this as well or should I create a new topic you think?

Again, thanks a lot!

Erik