mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-11 00:37:50 -06:00
Split profiles also per variant
But of course the variant names are strange in the new material profiles. Contributes to issue CURA-844.
This commit is contained in:
parent
9c7a28fa2d
commit
4d13622a6e
3 changed files with 60 additions and 17 deletions
|
@ -75,10 +75,10 @@ class MachineInstance:
|
|||
import VersionUpgrade21to22 # Import here to prevent circular dependencies.
|
||||
type_name = VersionUpgrade21to22.VersionUpgrade21to22.VersionUpgrade21to22.translatePrinter(self._type_name)
|
||||
active_material = VersionUpgrade21to22.VersionUpgrade21to22.VersionUpgrade21to22.translateProfile(self._active_material_name)
|
||||
variant = VersionUpgrade21to22.VersionUpgrade21to22.VersionUpgrade21to22.translateVariant(self._variant_name, type_name)
|
||||
active_profile = VersionUpgrade21to22.VersionUpgrade21to22.VersionUpgrade21to22.translateProfile(self._active_profile_name)
|
||||
if self._type_name in VersionUpgrade21to22.VersionUpgrade21to22.VersionUpgrade21to22.machinesWithMachineQuality(): #This machine now has machine-quality profiles.
|
||||
active_profile += "_" + active_material #That means that the profile was split into multiple.
|
||||
variant = VersionUpgrade21to22.VersionUpgrade21to22.VersionUpgrade21to22.translateVariant(self._variant_name, type_name)
|
||||
active_profile += "_" + active_material + "_" + variant #That means that the profile was split into multiple.
|
||||
if self._type_name in VersionUpgrade21to22.VersionUpgrade21to22.VersionUpgrade21to22.machinesWithMachineQuality(): #The current settings profile is now machine-specific.
|
||||
current_settings = "empty" #The profile didn't know the definition ID when it was upgraded, so it will have been invalid. Sorry, your current settings are lost now.
|
||||
else:
|
||||
|
|
|
@ -6,14 +6,6 @@ import io #To write config files to strings as if they were files.
|
|||
|
||||
import UM.VersionUpgrade
|
||||
|
||||
## The materials in Cura 2.2.
|
||||
#
|
||||
# This is required to know how to split old profiles if the old machine didn't
|
||||
# have material-specific profiles but the new machine has. This cannot be read
|
||||
# from the current source directory since the current source directory may be
|
||||
# a later version than Cura 2.2, so it must be stored in the upgrade plug-in.
|
||||
_new_materials = {"generic_abs", "generic_cpe", "generic_pla", "generic_pva"}
|
||||
|
||||
## Creates a new profile instance by parsing a serialised profile in version 1
|
||||
# of the file format.
|
||||
#
|
||||
|
@ -143,11 +135,18 @@ class Profile:
|
|||
configs.append(config)
|
||||
elif self._type != "material" and self._machine_type_id in VersionUpgrade21to22.VersionUpgrade21to22.VersionUpgrade21to22.machinesWithMachineQuality():
|
||||
#Split this profile into multiple profiles, one for each material.
|
||||
_new_materials = VersionUpgrade21to22.VersionUpgrade21to22.VersionUpgrade21to22.machinesWithMachineQuality()[self._machine_type_id]["materials"]
|
||||
_new_variants = VersionUpgrade21to22.VersionUpgrade21to22.VersionUpgrade21to22.machinesWithMachineQuality()[self._machine_type_id]["variants"]
|
||||
translated_machine = VersionUpgrade21to22.VersionUpgrade21to22.VersionUpgrade21to22.translatePrinter(self._machine_type_id)
|
||||
for material_id in _new_materials:
|
||||
filenames.append("{profile}_{material}".format(profile = self._filename, material = material_id))
|
||||
for variant_id in _new_variants:
|
||||
variant_id_new = VersionUpgrade21to22.VersionUpgrade21to22.VersionUpgrade21to22.translateVariant(variant_id, translated_machine)
|
||||
filenames.append("{profile}_{material}_{variant}".format(profile = self._filename, material = material_id, variant = variant_id_new))
|
||||
config_copy = configparser.ConfigParser(interpolation = None)
|
||||
config_copy.read_dict(config) #Copy the config to a new ConfigParser instance.
|
||||
config_copy.set("metadata", "material", material_id)
|
||||
variant_id_new_materials = VersionUpgrade21to22.VersionUpgrade21to22.VersionUpgrade21to22.translateVariantForMaterials(variant_id, translated_machine)
|
||||
config_copy.set("metadata", "material", "{material}_{variant}".format(material = material_id, variant = variant_id_new_materials))
|
||||
config_copy.set("general", "name", self._name + " " + material_id + " " + variant_id) #DEBUG
|
||||
configs.append(config_copy)
|
||||
else:
|
||||
configs.append(config)
|
||||
|
|
|
@ -13,12 +13,24 @@ from . import Profile # To upgrade profiles.
|
|||
#
|
||||
# These are the 2.1 machine identities with "has_machine_materials": true in
|
||||
# their definitions in Cura 2.2. So these are the machines for which profiles
|
||||
# need to split into multiple profiles, one for each material.
|
||||
# need to split into multiple profiles, one for each material and variant.
|
||||
#
|
||||
# Each machine has the materials and variants listed in which it needs to
|
||||
# split, since those might be different per machine.
|
||||
#
|
||||
# This should contain the definition as they are stated in the profiles. The
|
||||
# inheritance structure cannot be found at this stage, since the definitions
|
||||
# may have changed in later versions than 2.2.
|
||||
_machines_with_machine_quality = {"ultimaker2plus", "ultimaker2_extended_plus"}
|
||||
_machines_with_machine_quality = {
|
||||
"ultimaker2plus": {
|
||||
"materials": { "generic_abs", "generic_cpe", "generic_pla", "generic_pva" },
|
||||
"variants": { "0.25 mm", "0.4 mm", "0.6 mm", "0.8 mm" }
|
||||
},
|
||||
"ultimaker2_extended_plus": {
|
||||
"materials": { "generic_abs", "generic_cpe", "generic_pla", "generic_pva" },
|
||||
"variants": { "0.25 mm", "0.4 mm", "0.6 mm", "0.8 mm" }
|
||||
}
|
||||
}
|
||||
|
||||
## How to translate printer names from the old version to the new.
|
||||
_printer_translations = {
|
||||
|
@ -72,6 +84,24 @@ _variant_translations = {
|
|||
}
|
||||
}
|
||||
|
||||
## Cura 2.2's material profiles use a different naming scheme for variants.
|
||||
#
|
||||
# Getting pretty stressed out by this sort of thing...
|
||||
_variant_translations_materials = {
|
||||
"ultimaker2_plus": {
|
||||
"0.25 mm": "ultimaker2_plus_0.25_mm",
|
||||
"0.4 mm": "ultimaker2_plus_0.4_mm",
|
||||
"0.6 mm": "ultimaker2_plus_0.6_mm",
|
||||
"0.8 mm": "ultimaker2_plus_0.8_mm"
|
||||
},
|
||||
"ultimaker2_extended_plus": {
|
||||
"0.25 mm": "ultimaker2_plus_0.25_mm",
|
||||
"0.4 mm": "ultimaker2_plus_0.4_mm",
|
||||
"0.6 mm": "ultimaker2_plus_0.6_mm",
|
||||
"0.8 mm": "ultimaker2_plus_0.8_mm"
|
||||
}
|
||||
}
|
||||
|
||||
## Converts configuration from Cura 2.1's file formats to Cura 2.2's.
|
||||
#
|
||||
# It converts the machine instances and profiles.
|
||||
|
@ -199,3 +229,17 @@ class VersionUpgrade21to22(VersionUpgrade):
|
|||
if machine in _variant_translations and variant in _variant_translations[machine]:
|
||||
return _variant_translations[machine][variant]
|
||||
return variant
|
||||
|
||||
## Translates a variant name for the change from Cura 2.1 to 2.2 in
|
||||
# material profiles.
|
||||
#
|
||||
# \param variant The name of the variant in Cura 2.1.
|
||||
# \param machine The name of the machine this variant is part of in Cura
|
||||
# 2.2's naming.
|
||||
# \return The name of the corresponding variant for in material profiles
|
||||
# in Cura 2.2.
|
||||
@staticmethod
|
||||
def translateVariantForMaterials(variant, machine):
|
||||
if machine in _variant_translations_materials and variant in _variant_translations_materials[machine]:
|
||||
return _variant_translations_materials[machine][variant]
|
||||
return variant
|
Loading…
Add table
Add a link
Reference in a new issue