mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-13 19:56:00 +08:00
Use the new CuraEngine GCode protocol instead of temp files.
This commit is contained in:
parent
a669342fab
commit
d0703be1d6
@ -1,7 +1,9 @@
|
||||
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__()
|
||||
@ -9,11 +11,13 @@ class GCodeWriter(MeshWriter):
|
||||
|
||||
def write(self, file_name, storage_device, mesh_data):
|
||||
if 'gcode' in file_name:
|
||||
gcode = getattr(mesh_data, 'gcode', False)
|
||||
if gcode:
|
||||
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)
|
||||
f.write(gcode)
|
||||
for gcode in gcode_list:
|
||||
f.write(gcode)
|
||||
storage_device.closeFile(f)
|
||||
return True
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user