diff --git a/src/octoprint/util/gcodeInterpreter.py b/src/octoprint/util/gcodeInterpreter.py index d06766b8..0cc0aab2 100644 --- a/src/octoprint/util/gcodeInterpreter.py +++ b/src/octoprint/util/gcodeInterpreter.py @@ -294,15 +294,28 @@ class gcode(object): e = getCodeFloat(line, 'E') f = getCodeFloat(line, 'F') + if x is not None or y is not None or z is not None: + # this is a move + move = True + else: + # print head stays on position + move = False + oldPos = pos - newPos = Vector3D(x if x is not None else pos.x, - y if y is not None else pos.y, - z if z is not None else pos.z) + + # Use new coordinates if provided. If not provided, use prior coordinates in absolute + # and 0.0 in relative mode. + newPos = Vector3D(x if x is not None else (pos.x if posAbs else 0.0), + y if y is not None else (pos.y if posAbs else 0.0), + z if z is not None else (pos.z if posAbs else 0.0)) if posAbs: + # Absolute mode: scale coordinates and apply offsets pos = newPos * scale + posOffset else: + # Relative mode: scale and add to current position pos += newPos * scale + if f is not None and f != 0: feedrate = f @@ -310,10 +323,12 @@ class gcode(object): if absoluteE: # make sure e is relative e -= currentE[currentExtruder] - # If move includes extrusion, calculate new min/max coordinates of model - if e > 0.0: - # extrusion -> relevant for print area & dimensions + + # If move with extrusion, calculate new min/max coordinates of model + if e > 0.0 and move: + # extrusion and move -> relevant for print area & dimensions self._minMax.record(pos) + totalExtrusion[currentExtruder] += e currentE[currentExtruder] += e maxExtrusion[currentExtruder] = max(maxExtrusion[currentExtruder], @@ -417,7 +432,6 @@ class gcode(object): if throttle is not None: throttle() - if self.progressCallback is not None: self.progressCallback(100.0)