From e3d4a33954f19f8de1d1d5d92b5335aa7bbcdc37 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 19 Aug 2016 10:38:18 +0200 Subject: [PATCH] Fixed legacy profile reader Updated some settings that were changed from 2.1 to 2.2. Also fixed some architecture changes that were not changed correctly (or at all) CURA-1493 and CURA-1779 --- cura/Settings/CuraContainerRegistry.py | 1 + plugins/LegacyProfileReader/DictionaryOfDoom.json | 8 ++++---- plugins/LegacyProfileReader/LegacyProfileReader.py | 12 ++++++++---- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/cura/Settings/CuraContainerRegistry.py b/cura/Settings/CuraContainerRegistry.py index 990143f7bb..ed7cf3c430 100644 --- a/cura/Settings/CuraContainerRegistry.py +++ b/cura/Settings/CuraContainerRegistry.py @@ -170,6 +170,7 @@ class CuraContainerRegistry(ContainerRegistry): profile.addMetaDataEntry("material", self._activeMaterialId()) else: profile.setDefinition(ContainerRegistry.getInstance().findDefinitionContainers(id="fdmprinter")[0]) + ContainerRegistry.getInstance().addContainer(profile) ## Gets a list of profile writer plugins diff --git a/plugins/LegacyProfileReader/DictionaryOfDoom.json b/plugins/LegacyProfileReader/DictionaryOfDoom.json index 471604ddbc..db0d26b8e4 100644 --- a/plugins/LegacyProfileReader/DictionaryOfDoom.json +++ b/plugins/LegacyProfileReader/DictionaryOfDoom.json @@ -1,6 +1,6 @@ { "source_version": "15.04", - "target_version": 1, + "target_version": 2, "translation": { "machine_nozzle_size": "nozzle_size", @@ -21,7 +21,7 @@ "retraction_amount": "retraction_amount", "retraction_speed": "retraction_speed", "retraction_min_travel": "retraction_min_travel", - "retraction_hop": "retraction_hop", + "retraction_hop_enabled": "retraction_hop != 0", "speed_print": "print_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", @@ -29,7 +29,7 @@ "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", + "retraction_combing": "\"all\" if retraction_combing == \"All\" else \"noskin\" if retraction_combing == \"No Skin\" else \"off\"", "cool_fan_enabled": "fan_enabled", "cool_fan_speed_min": "fan_speed", "cool_fan_speed_max": "fan_speed_max", @@ -66,7 +66,7 @@ "meshfix_union_all_remove_holes": "fix_horrible_union_all_type_b", "meshfix_extensive_stitching": "fix_horrible_extensive_stitching", "meshfix_keep_open_polygons": "fix_horrible_use_open_bits", - "magic_mesh_surface_mode": "simple_mode", + "magic_mesh_surface_mode": "\"surface\" if simple_mode else \"normal\"", "magic_spiralize": "spiralize", "prime_tower_enable": "wipe_tower", "prime_tower_size": "math.sqrt(float(wipe_tower_volume) / float(layer_height))", diff --git a/plugins/LegacyProfileReader/LegacyProfileReader.py b/plugins/LegacyProfileReader/LegacyProfileReader.py index 19154c9c5a..a3e4e60b6a 100644 --- a/plugins/LegacyProfileReader/LegacyProfileReader.py +++ b/plugins/LegacyProfileReader/LegacyProfileReader.py @@ -111,7 +111,8 @@ class LegacyProfileReader(ProfileReader): if "translation" not in dict_of_doom: Logger.log("e", "Dictionary of Doom has no translation. Is it the correct JSON file?") return None - current_printer = Application.getInstance().getGlobalContainerStack().findContainer({ }, DefinitionContainer) + current_printer_definition = Application.getInstance().getGlobalContainerStack().getBottom() + profile.setDefinition(current_printer_definition) 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") @@ -121,10 +122,13 @@ class LegacyProfileReader(ProfileReader): except Exception: #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.") continue - if new_value != value_using_defaults and current_printer.findDefinitions(key = new_setting).default_value != new_value: #Not equal to the default in the new Cura OR the default in the legacy Cura. - profile.setSettingValue(new_setting, new_value) #Store the setting in the profile! + definitions = current_printer_definition.findDefinitions(key = new_setting) + if definitions: + if new_value != value_using_defaults and definitions[0].default_value != new_value: # Not equal to the default in the new Cura OR the default in the legacy Cura. + profile.setProperty(new_setting, "value", new_value) # Store the setting in the profile! - if len(profile.getChangedSettings()) == 0: + if len(profile.getAllKeys()) == 0: Logger.log("i", "A legacy profile was imported but everything evaluates to the defaults, creating an empty profile.") profile.setDirty(True) + profile.addMetaDataEntry("type", "quality") return profile \ No newline at end of file