From c8273785cd73f3f11652f17899c25e3e8f005c15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Fri, 11 Nov 2016 11:52:33 +0100 Subject: [PATCH] Fix position tracking of virtual printer Wasn't taking relative moves into account for coordinate persistence. --- .../plugins/virtual_printer/virtual.py | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/octoprint/plugins/virtual_printer/virtual.py b/src/octoprint/plugins/virtual_printer/virtual.py index 2ae3ba86..f4b6c4b7 100644 --- a/src/octoprint/plugins/virtual_printer/virtual.py +++ b/src/octoprint/plugins/virtual_printer/virtual.py @@ -705,7 +705,11 @@ class VirtualPrinter(object): duration = max(duration, x * self._unitModifier / float(self.speeds["x"]) * 60.0) else: duration = max(duration, (x - self._lastX) * self._unitModifier / float(self.speeds["x"]) * 60.0) - self._lastX = x + + if self._relative and self._lastX is not None: + self._lastX += x + else: + self._lastX = x except: pass if matchY is not None: @@ -715,7 +719,11 @@ class VirtualPrinter(object): duration = max(duration, y * self._unitModifier / float(self.speeds["y"]) * 60.0) else: duration = max(duration, (y - self._lastY) * self._unitModifier / float(self.speeds["y"]) * 60.0) - self._lastY = y + + if self._relative and self._lastY is not None: + self._lastY += y + else: + self._lastY = y except: pass if matchZ is not None: @@ -725,7 +733,11 @@ class VirtualPrinter(object): duration = max(duration, z * self._unitModifier / float(self.speeds["z"]) * 60.0) else: duration = max(duration, (z - self._lastZ) * self._unitModifier / float(self.speeds["z"]) * 60.0) - self._lastZ = z + + if self._relative and self._lastZ is not None: + self._lastZ += z + else: + self._lastZ = z except: pass if matchE is not None: @@ -735,7 +747,11 @@ class VirtualPrinter(object): duration = max(duration, e * self._unitModifier / float(self.speeds["e"]) * 60.0) else: duration = max(duration, (e - self._lastE) * self._unitModifier / float(self.speeds["e"]) * 60.0) - self._lastE = e + + if self._relative and self._lastE is not None: + self._lastE += e + else: + self._lastE = e except: pass