From 731fd41ecde914600bde443ec791b58078d27fbd Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Wed, 13 Jan 2016 15:42:15 +0100 Subject: [PATCH 1/9] If specific speed setting is 0, use print_speed Something that was not in the translation document: If a speed setting for a specific part is 0 (such as infill_speed) then the global print speed should be used. Contributes to issue CURA-37. --- plugins/LegacyProfileReader/DictionaryOfDoom.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/LegacyProfileReader/DictionaryOfDoom.json b/plugins/LegacyProfileReader/DictionaryOfDoom.json index 6ff6dac4dd..26eb2904e9 100644 --- a/plugins/LegacyProfileReader/DictionaryOfDoom.json +++ b/plugins/LegacyProfileReader/DictionaryOfDoom.json @@ -1,7 +1,7 @@ { "source_version": "15.04", "target_version": 1, - + "translation": { "line_width": "nozzle_size", "layer_height": "layer_height", @@ -24,11 +24,11 @@ "retraction_min_travel": "retraction_min_travel", "retraction_hop": "retraction_hop", "speed_print": "print_speed", - "speed_infill": "infill_speed", - "speed_wall_0": "inset0_speed", - "speed_wall_x": "insetx_speed", - "speed_topbottom": "solidarea_speed", - "speed_travel": "travel_speed", + "speed_infill": "infill_speed if (infill_speed != 0) else print_speed", + "speed_wall_0": "inset0_speed if (inset0_speed != 0) else print_speed", + "speed_wall_x": "insetx_speed if (insetx_speed != 0) else print_speed", + "speed_topbottom": "solidarea_speed if (solidarea_speed != 0) else print_speed", + "speed_travel": "travel_speed if (travel_speed != 0) else travel_speed", "speed_layer_0": "bottom_layer_speed", "retraction_combing": "retraction_combing", "cool_fan_enabled": "fan_enabled", From ef3b5792b4b209dcd8504e1e149db9fe4ff158b1 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Wed, 13 Jan 2016 15:52:38 +0100 Subject: [PATCH 2/9] Fix retraction combing import Retraction combing was an enum (a fact which was not documented). This enum must be parsed to a boolean. The 'no skin' option now evaluates to true since it is not implemented in the new Cura. Contributes to issue CURA-37. --- plugins/LegacyProfileReader/DictionaryOfDoom.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/LegacyProfileReader/DictionaryOfDoom.json b/plugins/LegacyProfileReader/DictionaryOfDoom.json index 26eb2904e9..d246efabe3 100644 --- a/plugins/LegacyProfileReader/DictionaryOfDoom.json +++ b/plugins/LegacyProfileReader/DictionaryOfDoom.json @@ -30,7 +30,7 @@ "speed_topbottom": "solidarea_speed if (solidarea_speed != 0) else print_speed", "speed_travel": "travel_speed if (travel_speed != 0) else travel_speed", "speed_layer_0": "bottom_layer_speed", - "retraction_combing": "retraction_combing", + "retraction_combing": "True if (retraction_combing == \"All\" or retraction_combing == \"No Skin\") else False", "cool_fan_enabled": "fan_enabled", "cool_fan_speed_min": "fan_speed", "cool_fan_speed_max": "fan_speed_max", From 3195684892b4b9d2748309cffafe5526180eaa55 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Wed, 13 Jan 2016 15:55:09 +0100 Subject: [PATCH 3/9] Parse speed settings as string In the evaluation that's passed from the Dictionary of Doom, the settings are still strings so you can only parse the settings as string... Contributes to issue CURA-37. --- plugins/LegacyProfileReader/DictionaryOfDoom.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/LegacyProfileReader/DictionaryOfDoom.json b/plugins/LegacyProfileReader/DictionaryOfDoom.json index d246efabe3..a340fdbea2 100644 --- a/plugins/LegacyProfileReader/DictionaryOfDoom.json +++ b/plugins/LegacyProfileReader/DictionaryOfDoom.json @@ -24,11 +24,11 @@ "retraction_min_travel": "retraction_min_travel", "retraction_hop": "retraction_hop", "speed_print": "print_speed", - "speed_infill": "infill_speed if (infill_speed != 0) else print_speed", - "speed_wall_0": "inset0_speed if (inset0_speed != 0) else print_speed", - "speed_wall_x": "insetx_speed if (insetx_speed != 0) else print_speed", - "speed_topbottom": "solidarea_speed if (solidarea_speed != 0) else print_speed", - "speed_travel": "travel_speed if (travel_speed != 0) else travel_speed", + "speed_infill": "infill_speed if (infill_speed != \"0\") else print_speed", + "speed_wall_0": "inset0_speed if (inset0_speed != \"0\") else print_speed", + "speed_wall_x": "insetx_speed if (insetx_speed != \"0\") else print_speed", + "speed_topbottom": "solidarea_speed if (solidarea_speed != \"0\") else print_speed", + "speed_travel": "travel_speed if (travel_speed != \"0\") else travel_speed", "speed_layer_0": "bottom_layer_speed", "retraction_combing": "True if (retraction_combing == \"All\" or retraction_combing == \"No Skin\") else False", "cool_fan_enabled": "fan_enabled", From 5d4cceb47c080b8efbbc25c7f6a998c3f2a8ed42 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Wed, 13 Jan 2016 16:16:00 +0100 Subject: [PATCH 4/9] Don't add a setting if it's the default If the imported setting is the default in the new Cura, don't add it to the profile. Contributes to issue CURA-37. --- plugins/LegacyProfileReader/LegacyProfileReader.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/LegacyProfileReader/LegacyProfileReader.py b/plugins/LegacyProfileReader/LegacyProfileReader.py index 5d89a85978..e5a4f575b3 100644 --- a/plugins/LegacyProfileReader/LegacyProfileReader.py +++ b/plugins/LegacyProfileReader/LegacyProfileReader.py @@ -74,7 +74,7 @@ class LegacyProfileReader(ProfileReader): try: with open(os.path.join(PluginRegistry.getInstance().getPluginPath("LegacyProfileReader"), "DictionaryOfDoom.json"), "r", -1, "utf-8") as f: - dict_of_doom = json.load(f) #Parse the Dictionary of Doom. + dict_of_doom = json.load(f) #Parse the Dictionary of Doom. except IOError as e: Logger.log("e", "Could not open DictionaryOfDoom.json for reading: %s", str(e)) return None @@ -97,6 +97,7 @@ class LegacyProfileReader(ProfileReader): old_setting_expression = dict_of_doom["translation"][new_setting] compiled = compile(old_setting_expression, new_setting, "eval") new_value = eval(compiled, {"math": math}, legacy_settings) #Pass the legacy settings as local variables to allow access to in the evaluation. - profile.setSettingValue(new_setting, new_value) #Store the setting in the profile! + if profile.getSettingValue(new_setting) != new_value: #Not equal to the default. + profile.setSettingValue(new_setting, new_value) #Store the setting in the profile! return profile \ No newline at end of file From 8b72834c9b3013c6c7375a239e24f4d0abe07af4 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Wed, 13 Jan 2016 16:24:20 +0100 Subject: [PATCH 5/9] Remove skin_no_small_gaps_heuristic Apparently this setting doesn't exist in the legacy Cura. Contributes to issue CURA-37. --- plugins/LegacyProfileReader/DictionaryOfDoom.json | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/LegacyProfileReader/DictionaryOfDoom.json b/plugins/LegacyProfileReader/DictionaryOfDoom.json index a340fdbea2..8f3a25e523 100644 --- a/plugins/LegacyProfileReader/DictionaryOfDoom.json +++ b/plugins/LegacyProfileReader/DictionaryOfDoom.json @@ -10,7 +10,6 @@ "top_bottom_thickness": "solid_layer_thickness", "top_thickness": "0 if (solid_top == \"False\") else solid_layer_thickness", "bottom_thickness": "0 if (solid_bottom == \"False\") else solid_layer_thickness", - "skin_no_small_gaps_heuristic": "fix_horrible_extensive_stitching", "infill_sparse_density": "fill_density", "infill_overlap": "fill_overlap", "infill_before_walls": "perimeter_before_infill", From a4777ac2ed9f0f4042996fd40186ca9fe5c3fe97 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Wed, 13 Jan 2016 16:32:38 +0100 Subject: [PATCH 6/9] Correct wall thickness setting The shell thickness also governs the top_bottom_thickness, which is not desired. Contributes to issue CURA-37. --- plugins/LegacyProfileReader/DictionaryOfDoom.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/LegacyProfileReader/DictionaryOfDoom.json b/plugins/LegacyProfileReader/DictionaryOfDoom.json index 8f3a25e523..10b4a1ad6f 100644 --- a/plugins/LegacyProfileReader/DictionaryOfDoom.json +++ b/plugins/LegacyProfileReader/DictionaryOfDoom.json @@ -6,7 +6,7 @@ "line_width": "nozzle_size", "layer_height": "layer_height", "layer_height_0": "bottom_thickness", - "shell_thickness": "wall_thickness", + "wall_thickness": "wall_thickness", "top_bottom_thickness": "solid_layer_thickness", "top_thickness": "0 if (solid_top == \"False\") else solid_layer_thickness", "bottom_thickness": "0 if (solid_bottom == \"False\") else solid_layer_thickness", From 7f1a746a452cc592d0e634529590cb2674ffa384 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Wed, 13 Jan 2016 16:33:39 +0100 Subject: [PATCH 7/9] Make infill_before_walls opposite The perimeter_before_infill setting was opposite of infill_before_walls, so turn this boolean around. Contributes to issue CURA-37. --- plugins/LegacyProfileReader/DictionaryOfDoom.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/LegacyProfileReader/DictionaryOfDoom.json b/plugins/LegacyProfileReader/DictionaryOfDoom.json index 10b4a1ad6f..b14994b1c1 100644 --- a/plugins/LegacyProfileReader/DictionaryOfDoom.json +++ b/plugins/LegacyProfileReader/DictionaryOfDoom.json @@ -12,7 +12,7 @@ "bottom_thickness": "0 if (solid_bottom == \"False\") else solid_layer_thickness", "infill_sparse_density": "fill_density", "infill_overlap": "fill_overlap", - "infill_before_walls": "perimeter_before_infill", + "infill_before_walls": "False if (perimeter_before_infill == \"True\") else True", "material_print_temperature": "print_temperature", "material_bed_temperature": "print_bed_temperature", "material_diameter": "filament_diameter", From 9feb609fbace17bc2d67bfad3d04e9e7a9f51c8b Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Wed, 13 Jan 2016 16:59:05 +0100 Subject: [PATCH 8/9] Don't add a setting if evaluation failed If the eval failed that is likely caused by a variable not existing. It now continues with evaluating other settings and just doesn't add the setting that depends on non-existing legacy settings. This happens when the imported profile is not complete or corrupt. Contributes to issue CURA-37. --- plugins/LegacyProfileReader/LegacyProfileReader.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/plugins/LegacyProfileReader/LegacyProfileReader.py b/plugins/LegacyProfileReader/LegacyProfileReader.py index e5a4f575b3..b32a317688 100644 --- a/plugins/LegacyProfileReader/LegacyProfileReader.py +++ b/plugins/LegacyProfileReader/LegacyProfileReader.py @@ -96,8 +96,11 @@ class LegacyProfileReader(ProfileReader): for new_setting in dict_of_doom["translation"]: #Evaluate all new settings that would get a value from the translations. old_setting_expression = dict_of_doom["translation"][new_setting] compiled = compile(old_setting_expression, new_setting, "eval") - new_value = eval(compiled, {"math": math}, legacy_settings) #Pass the legacy settings as local variables to allow access to in the evaluation. - if profile.getSettingValue(new_setting) != new_value: #Not equal to the default. - profile.setSettingValue(new_setting, new_value) #Store the setting in the profile! + try: + new_value = eval(compiled, {"math": math}, legacy_settings) #Pass the legacy settings as local variables to allow access to in the evaluation. + if profile.getSettingValue(new_setting) != new_value: #Not equal to the default. + profile.setSettingValue(new_setting, new_value) #Store the setting in the profile! + except Exception as e: #Probably some setting name that was missing or something else that went wrong in the ini file. + Logger.log("w", "Setting " + new_setting + " could not be set because the evaluation failed. Something is probably missing from the imported legacy profile.") return profile \ No newline at end of file From e82988f5e4b74946eb01383ec87884ffd1b5219f Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Wed, 13 Jan 2016 17:04:28 +0100 Subject: [PATCH 9/9] Correctly parse legacy speed settings with strange floats If the legacy profile contains float values serialised to '0.0' or '0.00' instead of just '0', this now works correctly instead of evaluating the string comparison to false. Contributes to issue CURA-37. --- plugins/LegacyProfileReader/DictionaryOfDoom.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/LegacyProfileReader/DictionaryOfDoom.json b/plugins/LegacyProfileReader/DictionaryOfDoom.json index b14994b1c1..cc6d867066 100644 --- a/plugins/LegacyProfileReader/DictionaryOfDoom.json +++ b/plugins/LegacyProfileReader/DictionaryOfDoom.json @@ -23,11 +23,11 @@ "retraction_min_travel": "retraction_min_travel", "retraction_hop": "retraction_hop", "speed_print": "print_speed", - "speed_infill": "infill_speed if (infill_speed != \"0\") else print_speed", - "speed_wall_0": "inset0_speed if (inset0_speed != \"0\") else print_speed", - "speed_wall_x": "insetx_speed if (insetx_speed != \"0\") else print_speed", - "speed_topbottom": "solidarea_speed if (solidarea_speed != \"0\") else print_speed", - "speed_travel": "travel_speed if (travel_speed != \"0\") else travel_speed", + "speed_infill": "infill_speed if (float(infill_speed) != 0) else print_speed", + "speed_wall_0": "inset0_speed if (float(inset0_speed) != 0) else print_speed", + "speed_wall_x": "insetx_speed if (float(insetx_speed) != 0) else print_speed", + "speed_topbottom": "solidarea_speed if (float(solidarea_speed) != 0) else print_speed", + "speed_travel": "travel_speed if (float(travel_speed) != 0) else travel_speed", "speed_layer_0": "bottom_layer_speed", "retraction_combing": "True if (retraction_combing == \"All\" or retraction_combing == \"No Skin\") else False", "cool_fan_enabled": "fan_enabled",