mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-10 16:27:51 -06:00
Add 'plugins/GCodeWriter/' from commit '6fc044387a
'
git-subtree-dir: plugins/GCodeWriter git-subtree-mainline:92afe31e37
git-subtree-split:6fc044387a
This commit is contained in:
commit
bda10b5ce5
2 changed files with 48 additions and 0 deletions
24
plugins/GCodeWriter/GCodeWriter.py
Normal file
24
plugins/GCodeWriter/GCodeWriter.py
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
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__()
|
||||||
|
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
|
||||||
|
|
||||||
|
return False
|
24
plugins/GCodeWriter/__init__.py
Normal file
24
plugins/GCodeWriter/__init__.py
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
from . import GCodeWriter
|
||||||
|
|
||||||
|
from UM.i18n import i18nCatalog
|
||||||
|
|
||||||
|
catalog = i18nCatalog('plugins')
|
||||||
|
|
||||||
|
def getMetaData():
|
||||||
|
return {
|
||||||
|
'type': 'mesh_writer',
|
||||||
|
'plugin': {
|
||||||
|
'name': 'GCode Writer',
|
||||||
|
'author': 'Arjen Hiemstra',
|
||||||
|
'version': '1.0',
|
||||||
|
'description': catalog.i18nc('GCode Writer Plugin Description', 'Writes GCode to a file')
|
||||||
|
},
|
||||||
|
|
||||||
|
'mesh_writer': {
|
||||||
|
'extension': 'gcode',
|
||||||
|
'description': catalog.i18nc('GCode Writer File Description', 'GCode File')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def register(app):
|
||||||
|
return {"mesh_writer":GCodeWriter.GCodeWriter()}
|
Loading…
Add table
Add a link
Reference in a new issue