Check for updatable machines after the machine_definition_id changes

So that we can account for the issue with the Dagoma printers (CURA-7517), which when they were
updated, the dagoma_discoeasy200 (dual extruder) was renamed to dagoma_discoeasy200_bicolor
and the dagoma_discoeasy200 became single extrusion. In this case, the project files created
before 4.6 should look for the dual extrusion dagomas (dagoma_discoeasy200_bicolor).

CURA-7644
This commit is contained in:
Kostas Karmas 2020-10-02 16:57:21 +02:00
parent 1dc8840ba8
commit 543daa52c9

View File

@ -438,7 +438,6 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
machine_definition_id = definition_containers["machine"][0]["id"] # type: str machine_definition_id = definition_containers["machine"][0]["id"] # type: str
machine_type = definition_containers["machine"][0]["name"] # type: str machine_type = definition_containers["machine"][0]["name"] # type: str
variant_type_name = definition_containers["machine"][0].get("variants_name", variant_type_name) variant_type_name = definition_containers["machine"][0].get("variants_name", variant_type_name)
updatable_machines = self._getUpdatableMachines(machine_definition_id) # type: List[ContainerStack]
# Pre read data from the material profiles # Pre read data from the material profiles
material_labels_dict, root_materials_dict = self._preReadMaterialDataFromArchive(archive) material_labels_dict, root_materials_dict = self._preReadMaterialDataFromArchive(archive)
@ -467,8 +466,11 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
# Check if the definition has been changed (this usually happens due to an upgrade) # Check if the definition has been changed (this usually happens due to an upgrade)
id_list = self._getContainerIdListFromSerialized(serialized_global_stack) id_list = self._getContainerIdListFromSerialized(serialized_global_stack)
if id_list[7] != machine_definition_id: if id_list[_ContainerIndexes.Definition] != machine_definition_id:
machine_definition_id = id_list[7] machine_definition_id = id_list[_ContainerIndexes.Definition]
# Get all the existing Cura machines that have the same definition id as the project file machine.
updatable_machines = self._getUpdatableMachines(machine_definition_id) # type: List[ContainerStack]
existing_stacks = self._container_registry.findContainerStacks(name = machine_name, type = "machine") existing_stacks = self._container_registry.findContainerStacks(name = machine_name, type = "machine")
existing_global_stack = None existing_global_stack = None
@ -483,11 +485,11 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
if existing_global_stack.getContainer(index).getId() != container_id: if existing_global_stack.getContainer(index).getId() != container_id:
self._conflicts_found["machine"] = True self._conflicts_found["machine"] = True
break break
else:
# The specific machine in the profile was not found, but similar machines exist in Cura and they can be # The specific machine in the project file was not found, but similar machines may exist in Cura. If that's
# used instead. # the case, any of these similar machines can be used when opening this project file.
if updatable_machines and not self._containers_found["machine"]: if updatable_machines:
self._containers_found["machine"] = True self._containers_found["machine"] = True
# Get quality type # Get quality type
parser = ConfigParser(interpolation = None) parser = ConfigParser(interpolation = None)