mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-05-04 03:53:59 +08:00
27 lines
789 B
Python
27 lines
789 B
Python
# Copyright (c) 2015 Ultimaker B.V.
|
|
# Cura is released under the terms of the AGPLv3 or higher.
|
|
|
|
from UM.Mesh.MeshWriter import MeshWriter
|
|
from UM.Logger import Logger
|
|
from UM.Application import Application
|
|
import io
|
|
|
|
|
|
class GCodeWriter(MeshWriter):
|
|
def __init__(self):
|
|
super().__init__()
|
|
|
|
def write(self, stream, node, mode = MeshWriter.OutputMode.TextMode):
|
|
if mode != MeshWriter.OutputMode.TextMode:
|
|
Logger.log("e", "GCode Writer does not support non-text mode")
|
|
return False
|
|
|
|
scene = Application.getInstance().getController().getScene()
|
|
gcode_list = getattr(scene, "gcode_list")
|
|
if gcode_list:
|
|
for gcode in gcode_list:
|
|
stream.write(gcode)
|
|
return True
|
|
|
|
return False
|