diff options
author | Diego Prado Gesto <d.pradogesto@ultimaker.com> | 2018-04-12 12:49:38 +0300 |
---|---|---|
committer | Diego Prado Gesto <d.pradogesto@ultimaker.com> | 2018-04-12 12:49:38 +0300 |
commit | 2d30315ecfc2df1a8065de2b3fb4241d87e90580 (patch) | |
tree | c64e9fcb1d86386c2c967a68104a93a9609320a1 /plugins/GCodeWriter | |
parent | b7b48927c2da21a8877bb8c242f46cae6c32216a (diff) |
CURA-5220 Skip storing the settings in the GCode if they already are.
Diffstat (limited to 'plugins/GCodeWriter')
-rw-r--r-- | plugins/GCodeWriter/GCodeWriter.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/plugins/GCodeWriter/GCodeWriter.py b/plugins/GCodeWriter/GCodeWriter.py index ccd881afdc..f25e249db1 100644 --- a/plugins/GCodeWriter/GCodeWriter.py +++ b/plugins/GCodeWriter/GCodeWriter.py @@ -42,6 +42,8 @@ class GCodeWriter(MeshWriter): re.escape("\r"): "\\r" # Carriage return. Windows users may need this for visualisation in their editors. } + _setting_keyword = ";SETTING_" + def __init__(self): super().__init__() @@ -69,11 +71,15 @@ class GCodeWriter(MeshWriter): return False gcode_list = gcode_dict.get(active_build_plate, None) if gcode_list is not None: + has_settings = False for gcode in gcode_list: + if gcode[:len(self._setting_keyword)] == self._setting_keyword: + has_settings = True stream.write(gcode) # Serialise the current container stack and put it at the end of the file. - settings = self._serialiseSettings(Application.getInstance().getGlobalContainerStack()) - stream.write(settings) + if not has_settings: + settings = self._serialiseSettings(Application.getInstance().getGlobalContainerStack()) + stream.write(settings) return True return False @@ -108,7 +114,7 @@ class GCodeWriter(MeshWriter): container_registry = self._application.getContainerRegistry() quality_manager = self._application.getQualityManager() - prefix = ";SETTING_" + str(GCodeWriter.version) + " " # The prefix to put before each line. + prefix = self._setting_keyword + str(GCodeWriter.version) + " " # The prefix to put before each line. prefix_length = len(prefix) quality_type = stack.quality.getMetaDataEntry("quality_type") |