Skip to content

Commit ecba95c

Browse files
committed
fix gcode serialization
fixes #14
1 parent cbc0624 commit ecba95c

File tree

4 files changed

+25
-41
lines changed

4 files changed

+25
-41
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog of Cura-DuetRRFPlugin
22

3+
## v0.0.17: 2018-08-10
4+
* fix missing settings at the end of the gcode file
5+
* make use of the default GCodeWrite that Cura uses for "Save to File"
6+
37
## v0.0.16: 2018-04-11
48
* improve simulation mode
59

DuetRRFOutputDevice.py

Lines changed: 12 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import os.path
2-
from io import StringIO
3-
from time import time, sleep
42
import datetime
53
import base64
64
import urllib
75
import json
6+
from io import StringIO
7+
from time import time, sleep
8+
from typing import cast
89

910
from PyQt5 import QtNetwork
1011
from PyQt5.QtCore import QFile, QUrl, QObject, QCoreApplication, QByteArray, QTimer, pyqtProperty, pyqtSignal, pyqtSlot
@@ -14,6 +15,8 @@
1415
from UM.Application import Application
1516
from UM.Logger import Logger
1617
from UM.Message import Message
18+
from UM.Mesh.MeshWriter import MeshWriter
19+
from UM.PluginRegistry import PluginRegistry
1720
from UM.OutputDevice.OutputDevice import OutputDevice
1821
from UM.OutputDevice import OutputDeviceError
1922

@@ -152,36 +155,13 @@ def onFilenameAccepted(self):
152155

153156
Logger.log("d", self._name_id + " | Loading gcode...")
154157

155-
# find the G-code for the active build plate to print
156-
version = Application.getInstance().getVersion()
157-
Logger.log("d", "Found Cura %s" % version)
158-
if version.startswith('3.0') or version.startswith('3.1'):
159-
# Cura 3.0 and 3.1
160-
gcode = getattr(Application.getInstance().getController().getScene(), "gcode_list")
161-
else:
162-
if version.startswith('3.2'):
163-
# Cura 3.2
164-
active_build_plate_id = Application.getInstance().getBuildPlateModel().activeBuildPlate
165-
else:
166-
# Cura 3.3 and later
167-
active_build_plate_id = Application.getInstance().getMultiBuildPlateModel().activeBuildPlate
168-
169-
gcode_dict = getattr(Application.getInstance().getController().getScene(), "gcode_dict")
170-
gcode = gcode_dict[active_build_plate_id]
171-
172-
lines = len(gcode)
173-
Logger.log("d", "Found %s lines of gcode." % lines)
174-
175-
# send all the gcode to self._stream
176-
nextYield = time() + 0.05
177-
i = 0
178-
for line in gcode:
179-
i += 1
180-
self._stream.write(line)
181-
if time() > nextYield:
182-
self._onProgress(i / lines)
183-
QCoreApplication.processEvents()
184-
nextYield = time() + 0.05
158+
# get the g-code through the GCodeWrite plugin
159+
# this serializes the actual scene and should produce the same output as "Save to File"
160+
gcode_writer = cast(MeshWriter, PluginRegistry.getInstance().getPluginObject("GCodeWriter"))
161+
success = gcode_writer.write(self._stream, None)
162+
if not success:
163+
Logger.log("e", "GCodeWrite failed.")
164+
return
185165

186166
# start
187167
Logger.log("d", self._name_id + " | Connecting...")

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
# Cura-DuetRRFPlugin
2-
Plugin for Cura 3 that adds output devices for a Duet RepRapFirmware printer: "Print", "Simulate", and "Upload".
2+
Plugin for Cura 3.4 that adds output devices for a Duet RepRapFirmware printer: "Print", "Simulate", and "Upload".
33

44
## Installation
55

66
With Cura not running, unpack the zip file from the [release](https://github.com/Kriechi/Cura-DuetRRFPlugin/releases/latest) to this specific folder:
77

88
### Windows
9-
`C:\Users\<username>\AppData\Roaming\cura\3.3\plugins\Cura-DuetRRFPlugin`
9+
`C:\Users\<username>\AppData\Roaming\cura\3.4\plugins\Cura-DuetRRFPlugin`
1010

1111
### Mac
12-
`~/Library/Application Support/Cura/3.3/plugins/Cura-DuetRRFPlugin`
12+
`~/Library/Application Support/Cura/3.4/plugins/Cura-DuetRRFPlugin`
1313

1414
### Linux
15-
`/home/<username>/.local/share/cura/3.3/plugins/Cura-DuetRRFPlugin`
15+
`/home/<username>/.local/share/cura/3.4/plugins/Cura-DuetRRFPlugin`
1616

1717
Be careful, the unzipper often tacks on the name of the zip as a folder at the
1818
bottom and you don't want it nested. You want the files to show up in that
19-
folder.
19+
folder.
2020

21-
Make sure that the plugin folder name is a listed above and it does not have
22-
any trailing version numbers (`-0.0.16`) or similar.
21+
Make sure that the plugin folder name is a listed above and it does not have
22+
any trailing version numbers (`-0.0.17`) or similar.
2323

2424
## Running from source
2525
Alternatively you can run from the source directly. It'll make it easy to

plugin.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "DuetRRF",
33
"author": "Thomas Kriechbaumer",
4-
"description": "Provides direct upload of gcode to DuetRRF.",
5-
"version": "0.0.16",
4+
"description": "Upload and Print to DuetWifi / DuetEthernet / Duet Maestro with RepRapFirmware.",
5+
"version": "0.0.17",
66
"api": 4
77
}

0 commit comments

Comments
 (0)