Browse Source

Fix GcodeStartEndFormatter to use fallback values

CURA-5901

Use values from the global stack (if exist) as fallback values.
Lipu Fei 6 years ago
parent
commit
bd42136712
1 changed files with 12 additions and 4 deletions
  1. 12 4
      plugins/CuraEngineBackend/StartSliceJob.py

+ 12 - 4
plugins/CuraEngineBackend/StartSliceJob.py

@@ -66,11 +66,19 @@ class GcodeStartEndFormatter(Formatter):
             return "{" + key + "}"
 
         key = key_fragments[0]
-        try:
-            return kwargs[str(extruder_nr)][key]
-        except KeyError:
+
+        default_value_str = "{" + key + "}"
+        value = default_value_str
+        # "-1" is global stack, and if the setting value exists in the global stack, use it as the fallback value.
+        if key in kwargs["-1"]:
+            value = kwargs["-1"]
+        if key in kwargs[str(extruder_nr)]:
+            value = kwargs[str(extruder_nr)][key]
+
+        if value == default_value_str:
             Logger.log("w", "Unable to replace '%s' placeholder in start/end g-code", key)
-            return "{" + key + "}"
+
+        return value
 
 
 ##  Job class that builds up the message of scene data to send to CuraEngine.