Multiple nodes in in loopBody of the LoopWhile function (or IF statements)

Capture

Basically this would be very easy to do in other programming languages, but I am very hard time figuring this one out.

I want to take a list, go through it, and add 5 to each of its values. So list of 0, 0, 10, 10 would become 5, 5, 15, 15

I figured out how to make a while loop that starts at 0, and stops loop when reaching end of the list. The problem is, I can only input one node into loopBody part, which i already used to increase index of the list.

So how would I do something like this:

X = 0
while X < 4 
{
X + 1;
list[X]+5;
}

I am running into same problem with the if node.

Also I am not looking for just a way to increase each number of the list, I am using this an example. What I am trying to figure out is just how to execute multiple statements during a while loop or an function

2 Likes

Thanks! I’m going to learn python now :slight_smile: I was wondering if it was possible to do it with the default nodes, but this is works too. Now all the possibilities :smiling_imp:

It’s usually best not to think in terms of looping when dealing with Dynamo. For true looping you should probably use python like @SHIBUJOSE shows. However, in your case it’s not necessary. Dynamo lacing will automatically “loop” through all of your input values, so you just need to think about the logic necessary to get you the right outcome.

If I understand your explanation, you want something like this:

2 Likes

You can use custom nodes or function compose to do what you’re looking to do - or imperative code (I don’t recommend that at this point thought - it’s still less stable than regular code blocks)

1 Like

I really appreciate all the help, especially with the different approaches. Kinda exciting to see that there is this much “action” in the Dynamo community. About a year ago I learned AutoLisp, and was a little bummed out that I hopped on that train this late. There are plenty of resources and forums for AutoLisp, however posting on forums would take forever to hear back.