About Loops

Loop operators let you reuse the result of a set of operations several times. When you work with loops, the result of each loop iteration is reused in the next iteration. A loop continues until a specified condition is reached.

Loop operators are valuable if you want to create recursive geometries. In the following topic, a simple example is used to describe the principles of loops within the app.

This page discusses:

Two operators are required to create a loop:

When you add the Loop Start operator in the graph editor, a Loop End operator is automatically added. Their iter parameters are connected by default:

Loop Definition

To create a loop, the set of operations on which the loop is applied need to be connected between the Loop Start node and the Loop End node.

Example

In our example, a Plus operation is connected between the loop operators.



  • The initial value at the start of the loop is the number 2 (val1).
  • The number of iterations is 10 (max).
  • The number to be added at each iteration of the Plus operation is 2 (Integer.2).
  • As a consequence, the final result of the loop is 22.

Loop Update

Loops have a specific update behavior:

  • During the execution of a loop, the operations connected to the loop operators are updated at each iteration.
  • Next, the output result of these operations is used as input for the Loop End operator.
  • Then, this input is copied as output to the Loop Start operator, and is reused as input variables in the operations connected to the loop operators.

This update behavior is repeated until a stop condition is fulfilled. Two conditions can stop a loop:

  • The current iteration number (iter parameter)

    If the current iteration number equals the maximum iteration number (max parameter) defined on the Start Loop operator, the loop stops.

  • The value of the stop parameter of the Loop End operator

    If the value of the stop parameter is true, the loop stops.

Loop Accumulator

The Loop Accumulator operator allows you to store the result of each iteration for a given output.

Tip: Connecting a Watch operator to a Loop Accumulator operator helps understand the intermediate steps of a loop execution.

For more information, see Loop Accumulator.