While Loop Levels Help

I am having some trouble using the while loop node with a list. I keep starting an infinite loop that will eventually crash Revit.

  1. Is there a way to force stop the loop so I dont have to restart every time? This is extremely cumbersome to test where I am going wrong or assigning the correct levels/lacing to my while loop node.

  2. Is it possible for the while loop node to operate on a list where the “Continue While” condition is analyzed per each item in the list? The items in my list would need to loop through the body different number of times.

  3. Does adjusting the list levels of the function nodes ahead of the while loop node affect anything?

  1. No - once you start code it cannot stop. This is common in most platforms (Dynamo, Python, C#) without adding a lot of extra code. The first thing you should do is ensure the loop has an out that will be hit.
  2. I believe so, but it is difficult to understand what you are after by this.
  3. Those would control the level at which the function works.

99.9% of the time while loops are not the way to go with Dynmo. List levels and lacing can usually accomplish what you are after, and they are much slower to execute due to their unknown runtime (the infinite loop could actually just be 36,000,000,000 loops, where each loop takes 1 second due to the complexity or data sources).

Best to explain what you’re after so we can first confirm the approach, and then I would recommend either scaling the action or limiting the number of attempts (generally I find limiting easiest in C#, followed distantly by Python, followed closely by Design Script, followed very distantly by nodes).