diff options
author | Ghostkeeper <rubend@tutanota.com> | 2016-05-24 03:24:11 +0300 |
---|---|---|
committer | Ghostkeeper <rubend@tutanota.com> | 2016-05-24 03:24:11 +0300 |
commit | 59b8d5c169bc762dfd80e847f1c6b23d10239217 (patch) | |
tree | 477c8dbee71947fd5523965bde34a207d68ccd95 /plugins/GCodeWriter | |
parent | fa1d262123387918414b74e69a33a57ee2e10910 (diff) |
Fix saving g-code to file
The settings that are serialised at the end of the g-code are now the serialised global container stack. That's fairly useless since the serialised version of a container stack just lists the IDs of the containers in the stack, not the settings themselves. One of these containers is likely a current_profile container and that's all the information you'll get from that serialisation.
Contributes to issue CURA-1278.
Diffstat (limited to 'plugins/GCodeWriter')
-rw-r--r-- | plugins/GCodeWriter/GCodeWriter.py | 23 | ||||
-rw-r--r-- | plugins/GCodeWriter/__init__.py | 2 |
2 files changed, 13 insertions, 12 deletions
diff --git a/plugins/GCodeWriter/GCodeWriter.py b/plugins/GCodeWriter/GCodeWriter.py index ee766ef221..5db25aeac2 100644 --- a/plugins/GCodeWriter/GCodeWriter.py +++ b/plugins/GCodeWriter/GCodeWriter.py @@ -32,7 +32,7 @@ class GCodeWriter(MeshWriter): 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") + Logger.log("e", "GCode Writer does not support non-text mode.") return False scene = Application.getInstance().getController().getScene() @@ -40,26 +40,27 @@ class GCodeWriter(MeshWriter): if gcode_list: for gcode in gcode_list: stream.write(gcode) - # Serialise the profile and put them at the end of the file. - profile = self._serialiseProfile(Application.getInstance().getMachineManager().getWorkingProfile()) - stream.write(profile) + # Serialise the current container stack and put it at the end of the file. + settings = self._serialiseSettings(Application.getInstance().getGlobalContainerStack()) + stream.write(settings) return True return False - ## Serialises the profile to prepare it for saving in the g-code. + ## Serialises a container stack to prepare it for writing at the end of the + # g-code. # - # The profile are serialised, and special characters (including newline) + # The settings are serialised, and special characters (including newline) # are escaped. # - # \param profile The profile to serialise. - # \return A serialised string of the profile. - def _serialiseProfile(self, profile): + # \param settings A container stack to serialise. + # \return A serialised string of the settings. + def _serialiseSettings(self, settings): prefix = ";SETTING_" + str(GCodeWriter.version) + " " # The prefix to put before each line. prefix_length = len(prefix) - # Serialise a deepcopy to remove the defaults from the profile - serialised = copy.deepcopy(profile).serialise() + #TODO: This just serialises the container stack, which only indicates the IDs of the containers in that stack, not the settings themselves, making this about 9001x as useless as the fax functionality in Adobe Acrobat. + serialised = settings.serialize() # Escape characters that have a special meaning in g-code comments. pattern = re.compile("|".join(GCodeWriter.escape_characters.keys())) diff --git a/plugins/GCodeWriter/__init__.py b/plugins/GCodeWriter/__init__.py index cd8a5d3418..efe3368c61 100644 --- a/plugins/GCodeWriter/__init__.py +++ b/plugins/GCodeWriter/__init__.py @@ -13,7 +13,7 @@ def getMetaData(): "author": "Ultimaker", "version": "1.0", "description": catalog.i18nc("@info:whatsthis", "Writes GCode to a file."), - "api": 2 + "api": 3 }, "mesh_writer": { |