From 2ed40fe2c6e72814cdcd9abbaaa2e2bb95c4c7a0 Mon Sep 17 00:00:00 2001 From: pnt103 <54410389+pnt103@users.noreply.github.com> Date: Thu, 25 Mar 2021 09:19:45 +0100 Subject: [PATCH] Get last position from previous layer instead. Old code was next-next layer, which is actually the layer _after_ the one that is meant. Fixes #9430 CURA-8116 --- .../PostProcessingPlugin/scripts/PauseAtHeight.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/plugins/PostProcessingPlugin/scripts/PauseAtHeight.py b/plugins/PostProcessingPlugin/scripts/PauseAtHeight.py index 4c3c9b4f33..eea4d38560 100644 --- a/plugins/PostProcessingPlugin/scripts/PauseAtHeight.py +++ b/plugins/PostProcessingPlugin/scripts/PauseAtHeight.py @@ -338,11 +338,6 @@ class PauseAtHeight(Script): if current_layer < pause_layer - nbr_negative_layers: continue - # Get X and Y from the next layer (better position for - # the nozzle) - next_layer = data[index + 1] - x, y = self.getNextXY(next_layer) - prev_layer = data[index - 1] prev_lines = prev_layer.split("\n") current_e = 0. @@ -353,6 +348,13 @@ class PauseAtHeight(Script): current_e = self.getValue(prevLine, "E", -1) if current_e >= 0: break + # and also find last X,Y + for prevLine in reversed(prev_lines): + if prevLine.startswith(("G0", "G1", "G2", "G3")): + if self.getValue(prevLine, "X") is not None and self.getValue(prevLine, "Y") is not None: + x = self.getValue(prevLine, "X") + y = self.getValue(prevLine, "Y") + break # Maybe redo the last layer. if redo_layer: