Browse Source

Fix the insert & timelapse script so that you can use both at the same time

CURA-5713
Jaime van Kessel 6 years ago
parent
commit
72eb90c7c1

+ 9 - 8
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

+ 6 - 5
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