From bd42136712e63abc8043a41ce1004275f4f94d5f Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Tue, 27 Nov 2018 09:49:35 +0100 Subject: [PATCH] Fix GcodeStartEndFormatter to use fallback values CURA-5901 Use values from the global stack (if exist) as fallback values. --- plugins/CuraEngineBackend/StartSliceJob.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/plugins/CuraEngineBackend/StartSliceJob.py b/plugins/CuraEngineBackend/StartSliceJob.py index 79b1e5249c..273dc0b6f6 100644 --- a/plugins/CuraEngineBackend/StartSliceJob.py +++ b/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.