how to specify the number of loop interations #1725
Replies: 2 comments 13 replies
-
Hi Ingrid, Loops are controlled by Python scripts that can be entered to the editor in Loop properties dock: The script shown in the image above in fact executes the loop three times. The return value of the script is used to decide if another iteration is necessary. Zero triggers another iteration while any other integer stops looping. You need to use Python's build-in When the script executes, it gets the value of loop counter as the first command line argument. You can use this value to stop the loop after a fixed number of executions. This is how it is done in the image above. Here is the same script with some comments: import sys
counter = int(sys.argv[1]) # Loop counter is supplied as first command line argument
exit(0 if counter < 3 else 1) # Exit code 0 = continue, anything else = break It might be possible to read an external variable in the script depending on where this variable is stored and use that in the stop condition. Loops are a bit complicated to use so let me know if you need further information! |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Dear Spine team,
I am using the loop capabilities of Spine.
I was wondering how to stop the workflow looping according to a variable?
Or is it possible to specify the number of times that a loop should be executed?
Thank you!
Ingrid
Beta Was this translation helpful? Give feedback.
All reactions