How to write a gcode loop for exactly N iterations?
-
I have a test macro file with an infinite loop which want to change to exactly 100 iterations. What is the gcode idiom for iterating N times where N is a constant?
while true g1 x0 y0 f30000 g1 x240 y0 f30000 g1 x240 y240 f30000 g1 x0 y240 f30000
-
@zapta this should work
while true If iterations > 100 Abort g1 x0 y0 f30000 g1 x240 y0 f30000 g1 x240 y240 f30000 g1 x0 y240 f30000
-
@zapta use:
while iterations <100
-
Thanks @jay_s_uk and @dc42. This is exactly what I was looking for.
BTW, since 'iterations' is loop specific, may be helpful to mention it also in the loop section.
https://duet3d.dozuki.com/Wiki/GCode_Meta_Commands#Section_Loop
-
@zapta said in How to write a gcode loop for exactly N iterations?:
BTW, since 'iterations' is loop specific, may be helpful to mention it also in the loop section.
Done!