mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-05-19 05:07:29 +08:00
Merge branch 'output_device' of github.com:Ultimaker/cura into output_device
This commit is contained in:
commit
7c3e53f714
@ -10,18 +10,17 @@ import io
|
||||
class GCodeWriter(MeshWriter):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self._gcode = None
|
||||
|
||||
def write(self, file_name, storage_device, mesh_data):
|
||||
if "gcode" in file_name:
|
||||
scene = Application.getInstance().getController().getScene()
|
||||
gcode_list = getattr(scene, "gcode_list")
|
||||
if gcode_list:
|
||||
f = storage_device.openFile(file_name, "wt")
|
||||
Logger.log("d", "Writing GCode to file %s", file_name)
|
||||
for gcode in gcode_list:
|
||||
f.write(gcode)
|
||||
storage_device.closeFile(f)
|
||||
return True
|
||||
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
|
||||
|
@ -13,15 +13,17 @@ def getMetaData():
|
||||
"name": "GCode Writer",
|
||||
"author": "Ultimaker",
|
||||
"version": "1.0",
|
||||
"description": catalog.i18nc("GCode Writer Plugin Description", "Writes GCode to a file")
|
||||
"description": catalog.i18nc("GCode Writer Plugin Description", "Writes GCode to a file"),
|
||||
"api": 2
|
||||
},
|
||||
|
||||
"mesh_writer": {
|
||||
"extension": "gcode",
|
||||
"description": catalog.i18nc("GCode Writer File Description", "GCode File"),
|
||||
"mime_types": [
|
||||
"text/x-gcode"
|
||||
]
|
||||
"output": [{
|
||||
"extension": "gcode",
|
||||
"description": catalog.i18nc("GCode Writer File Description", "GCode File"),
|
||||
"mime_type": "text/x-gcode",
|
||||
"mode": GCodeWriter.GCodeWriter.OutputMode.TextMode
|
||||
}]
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user