From 543daa52c9d1e64810c12dac283306d535149436 Mon Sep 17 00:00:00 2001 From: Kostas Karmas Date: Fri, 2 Oct 2020 16:57:21 +0200 Subject: [PATCH] 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 --- plugins/3MFReader/ThreeMFWorkspaceReader.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/plugins/3MFReader/ThreeMFWorkspaceReader.py b/plugins/3MFReader/ThreeMFWorkspaceReader.py index 8f1294cd26..29fb628363 100755 --- a/plugins/3MFReader/ThreeMFWorkspaceReader.py +++ b/plugins/3MFReader/ThreeMFWorkspaceReader.py @@ -438,7 +438,6 @@ class ThreeMFWorkspaceReader(WorkspaceReader): machine_definition_id = definition_containers["machine"][0]["id"] # type: str machine_type = definition_containers["machine"][0]["name"] # type: str 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 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) id_list = self._getContainerIdListFromSerialized(serialized_global_stack) - if id_list[7] != machine_definition_id: - machine_definition_id = id_list[7] + if id_list[_ContainerIndexes.Definition] != machine_definition_id: + 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_global_stack = None @@ -483,11 +485,11 @@ class ThreeMFWorkspaceReader(WorkspaceReader): if existing_global_stack.getContainer(index).getId() != container_id: self._conflicts_found["machine"] = True break - - # The specific machine in the profile was not found, but similar machines exist in Cura and they can be - # used instead. - if updatable_machines and not self._containers_found["machine"]: - self._containers_found["machine"] = True + else: + # The specific machine in the project file was not found, but similar machines may exist in Cura. If that's + # the case, any of these similar machines can be used when opening this project file. + if updatable_machines: + self._containers_found["machine"] = True # Get quality type parser = ConfigParser(interpolation = None)