mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-08 07:27:29 -06:00
Upgrade ultimaker2 quality_changes
CURA-4420 Ultimaker 2 quality_changes profiles were saved with definition = fdmprinter in Cura 2.7. In Cura 3.0, that should be "ultimaker2".
This commit is contained in:
parent
c9e8f7c743
commit
71f794f76d
2 changed files with 37 additions and 1 deletions
|
@ -3,6 +3,7 @@
|
|||
|
||||
import configparser #To parse preference files.
|
||||
import io #To serialise the preference files afterwards.
|
||||
import os
|
||||
|
||||
from UM.VersionUpgrade import VersionUpgrade #We're inheriting from this.
|
||||
|
||||
|
@ -93,6 +94,41 @@ class VersionUpgrade27to30(VersionUpgrade):
|
|||
parser.write(output)
|
||||
return [filename], [output.getvalue()]
|
||||
|
||||
## Upgrades the given quality changes container file from version 2.7 to 3.0.
|
||||
#
|
||||
# \param serialised The serialised form of the container file.
|
||||
# \param filename The name of the file to upgrade.
|
||||
def upgradeQualityChangesContainer(self, serialised, filename):
|
||||
parser = configparser.ConfigParser(interpolation=None)
|
||||
parser.read_string(serialised)
|
||||
|
||||
# Update the skin pre-shrink settings:
|
||||
# - Remove the old ones
|
||||
# - Do not add the new ones. The default values will be used for them.
|
||||
if parser.has_section("values"):
|
||||
for remove_key in ["expand_skins_into_infill", "expand_upper_skins", "expand_lower_skins"]:
|
||||
if remove_key in parser["values"]:
|
||||
del parser["values"][remove_key]
|
||||
|
||||
for each_section in ("general", "metadata"):
|
||||
if not parser.has_section(each_section):
|
||||
parser.add_section(each_section)
|
||||
|
||||
# Set the definition to "ultimaker2" for Ultimaker 2 quality changes
|
||||
if not parser.has_section("general"):
|
||||
parser.add_section("general")
|
||||
if os.path.basename(filename).startswith("ultimaker2_"):
|
||||
parser["general"]["definition"] = "ultimaker2"
|
||||
|
||||
# Update version numbers
|
||||
parser["general"]["version"] = "2"
|
||||
parser["metadata"]["setting_version"] = "3"
|
||||
|
||||
# Re-serialise the file.
|
||||
output = io.StringIO()
|
||||
parser.write(output)
|
||||
return [filename], [output.getvalue()]
|
||||
|
||||
## Upgrades the given instance container file from version 2.7 to 3.0.
|
||||
#
|
||||
# \param serialised The serialised form of the container file.
|
||||
|
|
|
@ -14,7 +14,7 @@ def getMetaData():
|
|||
("machine_stack", 3000002): ("machine_stack", 3000003, upgrade.upgradeStack),
|
||||
("extruder_train", 3000002): ("extruder_train", 3000003, upgrade.upgradeStack),
|
||||
|
||||
("quality_changes", 2000002): ("quality_changes", 2000003, upgrade.upgradeOtherContainer),
|
||||
("quality_changes", 2000002): ("quality_changes", 2000003, upgrade.upgradeQualityChangesContainer),
|
||||
("user", 2000002): ("user", 2000003, upgrade.upgradeOtherContainer),
|
||||
("quality", 2000002): ("quality", 2000003, upgrade.upgradeOtherContainer),
|
||||
("definition_changes", 2000002): ("definition_changes", 2000003, upgrade.upgradeOtherContainer),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue