return a gcode string generated from a list of steps
(steps: list, gcode_controls: GcodeControls = GcodeControls())
| 6 | |
| 7 | |
| 8 | def gcode(steps: list, gcode_controls: GcodeControls = GcodeControls()): |
| 9 | 'return a gcode string generated from a list of steps' |
| 10 | state = State(steps, gcode_controls) |
| 11 | # need a while loop because some classes may change the length of state.steps |
| 12 | while state.i < len(state.steps): |
| 13 | # call the gcode function of each class instance in 'steps' |
| 14 | gcode_line = state.steps[state.i].gcode(state) |
| 15 | if gcode_line != None: |
| 16 | state.gcode.append(gcode_line) |
| 17 | state.i += 1 |
| 18 | gc = '\n'.join(state.gcode) |
| 19 | |
| 20 | if gcode_controls.save_as != None: |
| 21 | filename = gcode_controls.save_as + datetime.now().strftime("__%d-%m-%Y__%H-%M-%S.gcode") |
| 22 | open(filename, 'w').write(gc) |
| 23 | else: |
| 24 | return gc |
nothing calls this directly
no test coverage detected