From 105d7a56154ed8c5323df3b8fc2c61941958da1e Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Wed, 22 Nov 2017 17:12:53 +0100 Subject: [PATCH] Return newly added single extruder The workspace reader needs to use it to get the correct material. Contributes to issue CURA-4604. --- cura/Settings/CuraContainerRegistry.py | 4 +++- plugins/3MFReader/ThreeMFWorkspaceReader.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/cura/Settings/CuraContainerRegistry.py b/cura/Settings/CuraContainerRegistry.py index 2c9e15b8c9..1674405824 100644 --- a/cura/Settings/CuraContainerRegistry.py +++ b/cura/Settings/CuraContainerRegistry.py @@ -409,7 +409,7 @@ class CuraContainerRegistry(ContainerRegistry): extruder_stack = None # if extruders are defined in the machine definition use those instead - if machine.extruders and len(machine.extruders) > 0: + if machine.extruders and "0" in machine.extruders: new_extruder_id = machine.extruders["0"].getId() extruder_stack = machine.extruders["0"] @@ -457,6 +457,8 @@ class CuraContainerRegistry(ContainerRegistry): self.addContainer(extruder_stack) + return extruder_stack + # Fix the extruders that were upgraded to ExtruderStack instances during addContainer. # The stacks are now responsible for setting the next stack on deserialize. However, # due to problems with loading order, some stacks may not have the proper next stack diff --git a/plugins/3MFReader/ThreeMFWorkspaceReader.py b/plugins/3MFReader/ThreeMFWorkspaceReader.py index a237460bab..aa81399b56 100755 --- a/plugins/3MFReader/ThreeMFWorkspaceReader.py +++ b/plugins/3MFReader/ThreeMFWorkspaceReader.py @@ -746,7 +746,7 @@ class ThreeMFWorkspaceReader(WorkspaceReader): # If not extruder stacks were saved in the project file (pre 3.1) create one manually # We re-use the container registry's addExtruderStackForSingleExtrusionMachine method for this if not extruder_stacks: - self._container_registry.addExtruderStackForSingleExtrusionMachine(global_stack, "fdmextruder") + extruder_stacks.append(self._container_registry.addExtruderStackForSingleExtrusionMachine(global_stack, "fdmextruder")) except: Logger.logException("w", "We failed to serialize the stack. Trying to clean up.")