mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-04-21 05:09:37 +08:00
Change definition ID upon reading profile
Implements CURA-6713.
This commit is contained in:
parent
c41af1b9a0
commit
2f917c2841
@ -241,12 +241,11 @@ class CuraContainerRegistry(ContainerRegistry):
|
||||
|
||||
# And check if the profile_definition matches either one (showing error if not):
|
||||
if profile_definition != expected_machine_definition:
|
||||
Logger.log("e", "Profile [%s] is for machine [%s] but the current active machine is [%s]. Will not import the profile", file_name, profile_definition, expected_machine_definition)
|
||||
return { "status": "error",
|
||||
"message": catalog.i18nc("@info:status Don't translate the XML tags <filename>!", "The machine defined in profile <filename>{0}</filename> ({1}) doesn't match with your current machine ({2}), could not import it.", file_name, profile_definition, expected_machine_definition)}
|
||||
Logger.log("d", "Profile {file_name} is for machine {profile_definition}, but the current active machine is {expected_machine_definition}. Changing profile's definition.".format(file_name = file_name, profile_definition = profile_definition, expected_machine_definition = expected_machine_definition))
|
||||
global_profile.setMetaDataEntry("definition", expected_machine_definition)
|
||||
for extruder_profile in extruder_profiles:
|
||||
extruder_profile.setMetaDataEntry("definition", expected_machine_definition)
|
||||
|
||||
# Fix the global quality profile's definition field in case it's not correct
|
||||
global_profile.setMetaDataEntry("definition", expected_machine_definition)
|
||||
quality_name = global_profile.getName()
|
||||
quality_type = global_profile.getMetaDataEntry("quality_type")
|
||||
|
||||
|
@ -4,11 +4,11 @@
|
||||
import configparser
|
||||
from typing import List, Optional, Tuple
|
||||
|
||||
from UM.PluginRegistry import PluginRegistry
|
||||
from UM.Logger import Logger
|
||||
from UM.Settings.ContainerFormatError import ContainerFormatError
|
||||
from UM.Settings.InstanceContainer import InstanceContainer # The new profile to make.
|
||||
from cura.CuraApplication import CuraApplication
|
||||
from cura.Machines.QualityManager import getMachineDefinitionIDForQualitySearch
|
||||
from cura.ReaderWriters.ProfileReader import ProfileReader
|
||||
|
||||
import zipfile
|
||||
@ -92,6 +92,10 @@ class CuraProfileReader(ProfileReader):
|
||||
except Exception as e:
|
||||
Logger.log("e", "Error while trying to parse profile: %s", str(e))
|
||||
return None
|
||||
|
||||
active_quality_definition = getMachineDefinitionIDForQualitySearch(CuraApplication.getInstance().getGlobalContainerStack().definition)
|
||||
if profile.getMetaDataEntry("definition") != active_quality_definition:
|
||||
profile.setMetaDataEntry("definition", active_quality_definition)
|
||||
return profile
|
||||
|
||||
## Upgrade a serialized profile to the current profile format.
|
||||
|
Loading…
x
Reference in New Issue
Block a user