diff --git a/plugins/VersionUpgrade/VersionUpgrade21to22/MachineInstance.py b/plugins/VersionUpgrade/VersionUpgrade21to22/MachineInstance.py index 894e9a8c7a..7582befca6 100644 --- a/plugins/VersionUpgrade/VersionUpgrade21to22/MachineInstance.py +++ b/plugins/VersionUpgrade/VersionUpgrade21to22/MachineInstance.py @@ -66,10 +66,13 @@ class MachineInstance: config.set("general", "type", self._type_name) config.set("general", "version", "2") # Hard-code version 2, since if this number changes the programmer MUST change this entire function. + import VersionUpgrade21to22 # Import here to prevent circular dependencies. + active_profile = VersionUpgrade21to22.VersionUpgrade21to22.VersionUpgrade21to22.translateProfile(self._active_profile_name) + active_material = VersionUpgrade21to22.VersionUpgrade21to22.VersionUpgrade21to22.translateProfile(self._active_material_name) containers = [ self._name, - self._active_profile_name, - self._active_material_name, + active_profile, + active_material, self._variant_name, self._type_name ] @@ -78,7 +81,6 @@ class MachineInstance: config.add_section("metadata") config.set("metadata", "type", "machine") - import VersionUpgrade21to22 # Import here to prevent circular dependencies. VersionUpgrade21to22.VersionUpgrade21to22.VersionUpgrade21to22.translateSettings(self._machine_setting_overrides) config.add_section("values") for key, value in self._machine_setting_overrides.items(): diff --git a/plugins/VersionUpgrade/VersionUpgrade21to22/VersionUpgrade21to22.py b/plugins/VersionUpgrade/VersionUpgrade21to22/VersionUpgrade21to22.py index f54609256d..641931c5a4 100644 --- a/plugins/VersionUpgrade/VersionUpgrade21to22/VersionUpgrade21to22.py +++ b/plugins/VersionUpgrade/VersionUpgrade21to22/VersionUpgrade21to22.py @@ -9,6 +9,13 @@ from . import MachineInstance # To upgrade machine instances. from . import Preferences #To upgrade preferences. from . import Profile # To upgrade profiles. +## How to translate profile names from the old version to the new. +_profile_translation = { + "PLA": "generic_pla", + "ABS": "generic_abs", + "CPE": "generic_cpe" +} + ## Converts configuration from Cura 2.1's file formats to Cura 2.2's. # # It converts the machine instances and profiles. @@ -69,6 +76,17 @@ class VersionUpgrade21to22(VersionUpgrade): printers[index] = "ultimaker2_plus" return printers + ## Translates a built-in profile name that might have changed since the + # last version. + # + # \param profile A profile name in the old version. + # \return The corresponding profile name in the new version. + @staticmethod + def translateProfile(profile): + if profile in _profile_translation: + return _profile_translation[profile] + return profile + ## Updates settings for the change from Cura 2.1 to 2.2. # # The keys and values of settings are changed to what they should be in