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
This commit is contained in:
pnt103 2021-03-25 09:19:45 +01:00 committed by Remco Burema
parent 91fe9e8ebf
commit 2ed40fe2c6
No known key found for this signature in database
GPG key ID: 215C49431D43F98C

View file

@ -338,11 +338,6 @@ class PauseAtHeight(Script):
if current_layer < pause_layer - nbr_negative_layers: if current_layer < pause_layer - nbr_negative_layers:
continue 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_layer = data[index - 1]
prev_lines = prev_layer.split("\n") prev_lines = prev_layer.split("\n")
current_e = 0. current_e = 0.
@ -353,6 +348,13 @@ class PauseAtHeight(Script):
current_e = self.getValue(prevLine, "E", -1) current_e = self.getValue(prevLine, "E", -1)
if current_e >= 0: if current_e >= 0:
break 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. # Maybe redo the last layer.
if redo_layer: if redo_layer: