From 72eb90c7c139ca3bd47b638cf0d7d3d90af327b3 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Wed, 13 Mar 2019 13:28:10 +0100 Subject: [PATCH] Fix the insert & timelapse script so that you can use both at the same time CURA-5713 --- .../scripts/InsertAtLayerChange.py | 17 +++++++++-------- .../PostProcessingPlugin/scripts/TimeLapse.py | 11 ++++++----- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/plugins/PostProcessingPlugin/scripts/InsertAtLayerChange.py b/plugins/PostProcessingPlugin/scripts/InsertAtLayerChange.py index 32fcc85fe1..c21993aad1 100644 --- a/plugins/PostProcessingPlugin/scripts/InsertAtLayerChange.py +++ b/plugins/PostProcessingPlugin/scripts/InsertAtLayerChange.py @@ -37,13 +37,14 @@ class InsertAtLayerChange(Script): for layer in data: # Check that a layer is being printed lines = layer.split("\n") - if ";LAYER:" in lines[0]: - index = data.index(layer) - if self.getSettingValueByKey("insert_location") == "before": - layer = gcode_to_add + layer - else: - layer = layer + gcode_to_add - - data[index] = layer + for line in lines: + if ";LAYER:" in line: + index = data.index(layer) + if self.getSettingValueByKey("insert_location") == "before": + layer = gcode_to_add + layer + else: + layer = layer + gcode_to_add + data[index] = layer + break return data diff --git a/plugins/PostProcessingPlugin/scripts/TimeLapse.py b/plugins/PostProcessingPlugin/scripts/TimeLapse.py index 76d9143459..36d0f6a058 100644 --- a/plugins/PostProcessingPlugin/scripts/TimeLapse.py +++ b/plugins/PostProcessingPlugin/scripts/TimeLapse.py @@ -85,10 +85,11 @@ class TimeLapse(Script): for layer in data: # Check that a layer is being printed lines = layer.split("\n") - if ";LAYER:" in lines[0]: - index = data.index(layer) - layer += gcode_to_append - - data[index] = layer + for line in lines: + if ";LAYER:" in line: + index = data.index(layer) + layer += gcode_to_append + data[index] = layer + break return data