From f328926be325117a74078c5e7ccab18d440fe060 Mon Sep 17 00:00:00 2001 From: Diego Prado Gesto Date: Mon, 23 Apr 2018 14:24:25 +0200 Subject: [PATCH] CURA-5275 Add the end point of the previous path also when there is a change in the tool. --- plugins/GCodeReader/FlavorParser.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/GCodeReader/FlavorParser.py b/plugins/GCodeReader/FlavorParser.py index 92233ba14f..2679cc23a4 100644 --- a/plugins/GCodeReader/FlavorParser.py +++ b/plugins/GCodeReader/FlavorParser.py @@ -362,13 +362,13 @@ class FlavorParser: else: Logger.log("w", "Encountered a unknown type (%s) while parsing g-code.", type) - # When the layer change is reached, the polygon is computed so we have just one layer per layer per extruder + # When the layer change is reached, the polygon is computed so we have just one layer per extruder if self._is_layers_in_file and line[:len(self._layer_keyword)] == self._layer_keyword: try: layer_number = int(line[len(self._layer_keyword):]) self._createPolygon(self._current_layer_thickness, current_path, self._extruder_offsets.get(self._extruder_number, [0, 0])) current_path.clear() - # start the new layer at the end position of the last layer + # Start the new layer at the end position of the last layer current_path.append([current_position.x, current_position.y, current_position.z, current_position.f, current_position.e[self._extruder_number], LayerPolygon.MoveCombingType]) # When using a raft, the raft layers are stored as layers < 0, it mimics the same behavior @@ -408,7 +408,11 @@ class FlavorParser: self._createPolygon(self._current_layer_thickness, current_path, self._extruder_offsets.get(self._extruder_number, [0, 0])) current_path.clear() + # When changing tool, store the end point of the previous path, then process the code and finally + # add another point with the new position of the head. + current_path.append([current_position.x, current_position.y, current_position.z, current_position.f, current_position.e[self._extruder_number], LayerPolygon.MoveCombingType]) current_position = self.processTCode(T, line, current_position, current_path) + current_path.append([current_position.x, current_position.y, current_position.z, current_position.f, current_position.e[self._extruder_number], LayerPolygon.MoveCombingType]) if line.startswith("M"): M = self._getInt(line, "M")