MCPcopy Create free account
hub / github.com/FullControlXYZ/fullcontrol / gcode

Function gcode

lab/fullcontrol/multiaxis/gcode/XYZBC/steps2gcode.py:8–24  ·  view source on GitHub ↗

return a gcode string generated from a list of steps

(steps: list, gcode_controls: GcodeControls = GcodeControls())

Source from the content-addressed store, hash-verified

6
7
8def 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

Callers

nothing calls this directly

Calls 3

GcodeControlsClass · 0.90
StateClass · 0.90
gcodeMethod · 0.45

Tested by

no test coverage detected