From 81203cd8b9a60ab34fc00054aeab8ef0430ecebd Mon Sep 17 00:00:00 2001 From: JPFrancoia Date: Tue, 5 Dec 2017 20:00:06 +0000 Subject: [PATCH] Fixes issue https://github.com/nallath/PostProcessingPlugin/issues/55. The extruder absolute position is reset to the value it had at te begining of the first layer redone. --- scripts/PauseAtHeight.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/scripts/PauseAtHeight.py b/scripts/PauseAtHeight.py index 925a5a7..f04ee9f 100644 --- a/scripts/PauseAtHeight.py +++ b/scripts/PauseAtHeight.py @@ -147,6 +147,9 @@ def execute(self, data: list): prevLayer = data[index - 1] prevLines = prevLayer.split("\n") current_e = 0. + + # Access last layer, browse it backwards to find + # last extruder absolute position for prevLine in reversed(prevLines): current_e = self.getValue(prevLine, 'E', -1) if current_e >= 0: @@ -157,6 +160,19 @@ def execute(self, data: list): prevLayer = data[index - i] layer = prevLayer + layer + # Get extruder's absolute position at the + # begining of the first layer redone + # see https://github.com/nallath/PostProcessingPlugin/issues/55 + if i == redo_layers: + prevLines = prevLayer.split("\n") + for line in prevLines: + new_e = self.getValue(line, 'E', + current_e) + + if new_e != current_e: + current_e = new_e + break + prepend_gcode = ";TYPE:CUSTOM\n" prepend_gcode += ";added code by post processing\n" prepend_gcode += ";script: PauseAtHeight.py\n"