From 6772dc9ea79736085773398c1c8917c8bc50d252 Mon Sep 17 00:00:00 2001 From: Ruben D Date: Wed, 9 May 2018 13:25:15 +0200 Subject: [PATCH] Show g-code in position it would print Rather than trying to retrieve from the g-code what the position was that it was originally sliced. It was trying to find whether it was sliced for a printer with center_is_zero by seeing if there are any negative coordinates in the g-code, which was faulty. Now we don't even try to do that any more. We just find where the print would end up if it were printed with the currently selected printer. Contributes to issue CURA-5068 and fixes #3634. --- plugins/GCodeReader/FlavorParser.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/plugins/GCodeReader/FlavorParser.py b/plugins/GCodeReader/FlavorParser.py index a0b112bc5e..9a043f4961 100644 --- a/plugins/GCodeReader/FlavorParser.py +++ b/plugins/GCodeReader/FlavorParser.py @@ -56,7 +56,6 @@ class FlavorParser: self._layer_number = 0 self._previous_z = 0 self._layer_data_builder = LayerDataBuilder.LayerDataBuilder() - self._center_is_zero = False self._is_absolute_positioning = True # It can be absolute (G90) or relative (G91) self._is_absolute_extrusion = True # It can become absolute (M82, default) or relative (M83) @@ -262,8 +261,6 @@ class FlavorParser: f = float(item[1:]) / 60 if item[0] == "E": e = float(item[1:]) - if self._is_absolute_positioning and ((x is not None and x < 0) or (y is not None and y < 0)): - self._center_is_zero = True params = self._position(x, y, z, f, e) return func(position, params, path) return position @@ -275,7 +272,7 @@ class FlavorParser: position.e.extend([0] * (self._extruder_number - len(position.e) + 1)) return position - def processMCode(self, M: int, line: str, position: Position, path: List[Position]) -> Position: + def processMCode(self, M: int, line: str, position: Position, path: List[List[Union[float, int]]]) -> Position: pass _type_keyword = ";TYPE:" @@ -458,10 +455,9 @@ class FlavorParser: Logger.log("w", "File doesn't contain any valid layers") settings = Application.getInstance().getGlobalContainerStack() - machine_width = settings.getProperty("machine_width", "value") - machine_depth = settings.getProperty("machine_depth", "value") - - if not self._center_is_zero: + if not settings.getProperty("machine_center_is_zero", "value"): + machine_width = settings.getProperty("machine_width", "value") + machine_depth = settings.getProperty("machine_depth", "value") scene_node.setPosition(Vector(-machine_width / 2, 0, machine_depth / 2)) Logger.log("d", "GCode loading finished")