Browse Source

add Marlin Advanced Pause Feature!

Sekisback 4 years ago
parent
commit
b458005e7e
1 changed files with 37 additions and 14 deletions
  1. 37 14
      plugins/PostProcessingPlugin/scripts/FilamentChange.py

+ 37 - 14
plugins/PostProcessingPlugin/scripts/FilamentChange.py

@@ -1,6 +1,9 @@
 # Copyright (c) 2019 Ultimaker B.V.
 # The PostProcessingPlugin is released under the terms of the AGPLv3 or higher.
 
+# Modifikation 06.09.2020
+# add checkbox, now you can choose and use configuration from Marlin Advanced Pause Feature!
+
 from typing import List
 from ..Script import Script
 
@@ -19,6 +22,14 @@ class FilamentChange(Script):
             "version": 2,
             "settings":
             {
+                "marlin": 
+                {
+                    "label": "Use Marlin Config?",
+                    "description": "Use configuration from Marlin Advanced Pause Feature!",
+                    "type": "bool",
+                    "default_value": true
+                },
+                
                 "layer_number":
                 {
                     "label": "Layer",
@@ -34,7 +45,9 @@ class FilamentChange(Script):
                     "description": "Initial filament retraction distance. The filament will be retracted with this amount before moving the nozzle away from the ongoing print.",
                     "unit": "mm",
                     "type": "float",
-                    "default_value": 30.0
+                    "default_value": 30.0,
+                    "enabled": "marlin == 0"
+                    
                 },
                 "later_retract":
                 {
@@ -42,7 +55,9 @@ class FilamentChange(Script):
                     "description": "Later filament retraction distance for removal. The filament will be retracted all the way out of the printer so that you can change the filament.",
                     "unit": "mm",
                     "type": "float",
-                    "default_value": 300.0
+                    "default_value": 300.0,
+                    "enabled": "marlin == 0"
+                    
                 },
                 "x_position":
                 {
@@ -50,7 +65,9 @@ class FilamentChange(Script):
                     "description": "Extruder X position. The print head will move here for filament change.",
                     "unit": "mm",
                     "type": "float",
-                    "default_value": 0
+                    "default_value": 0,
+                    "enabled": "marlin == 0"
+                    
                 },
                 "y_position":
                 {
@@ -58,7 +75,9 @@ class FilamentChange(Script):
                     "description": "Extruder Y position. The print head will move here for filament change.",
                     "unit": "mm",
                     "type": "float",
-                    "default_value": 0
+                    "default_value": 0,
+                    "enabled": "marlin == 0"
+                    
                 }
             }
         }"""
@@ -74,22 +93,26 @@ class FilamentChange(Script):
         later_retract = self.getSettingValueByKey("later_retract")
         x_pos = self.getSettingValueByKey("x_position")
         y_pos = self.getSettingValueByKey("y_position")
+        marlin_conf = self.getSettingValueByKey("marlin")
 
         color_change = "M600"
 
-        if initial_retract is not None and initial_retract > 0.:
-            color_change = color_change + (" E%.2f" % initial_retract)
-
-        if later_retract is not None and later_retract > 0.:
-            color_change = color_change + (" L%.2f" % later_retract)
+        if marlin_conf: 
+            color_change = color_change + " ; Generated by FilamentChange plugin\n"            
+        else:
+            if initial_retract is not None and initial_retract > 0.:
+                color_change = color_change + (" E%.2f" % initial_retract)
 
-        if x_pos is not None:
-            color_change = color_change + (" X%.2f" % x_pos)
+            if later_retract is not None and later_retract > 0.:
+                color_change = color_change + (" L%.2f" % later_retract)
 
-        if y_pos is not None:
-            color_change = color_change + (" Y%.2f" % y_pos)
+            if x_pos is not None:
+                color_change = color_change + (" X%.2f" % x_pos)
 
-        color_change = color_change + " ; Generated by FilamentChange plugin\n"
+            if y_pos is not None:
+                color_change = color_change + (" Y%.2f" % y_pos)
+                
+            color_change = color_change + " ; Generated by FilamentChange plugin\n"
 
         layer_targets = layer_nums.split(",")
         if len(layer_targets) > 0: