diff --git a/cura/Machines/ContainerTree.py b/cura/Machines/ContainerTree.py index 4299003b16..80681c902d 100644 --- a/cura/Machines/ContainerTree.py +++ b/cura/Machines/ContainerTree.py @@ -3,12 +3,11 @@ from UM.Logger import Logger from UM.Settings.ContainerRegistry import ContainerRegistry # To listen to containers being added. -from UM.Settings.DefinitionContainer import DefinitionContainer from UM.Settings.Interfaces import ContainerInterface from UM.Signal import Signal import cura.CuraApplication # Imported like this to prevent circular dependencies. from cura.Machines.MachineNode import MachineNode -from cura.Settings.ExtruderStack import ExtruderStack # To skip extruder stacks being added. +from cura.Settings.GlobalStack import GlobalStack # To listen only to global stacks being added. from typing import Dict, TYPE_CHECKING import time @@ -64,7 +63,7 @@ class ContainerTree: start_time = time.time() all_stacks = ContainerRegistry.getInstance().findContainerStacks() for stack in all_stacks: - if isinstance(stack, ExtruderStack): + if not isinstance(stack, GlobalStack): continue # Only want to load global stacks. We don't need to create a tree for extruder definitions. definition_id = stack.definition.getId() if definition_id not in self.machines: @@ -76,12 +75,10 @@ class ContainerTree: Logger.log("d", "Building the container tree took %s seconds", time.time() - start_time) ## When a printer gets added, we need to build up the tree for that container. - def _machineAdded(self, definition_container: ContainerInterface): - if not isinstance(definition_container, DefinitionContainer): + def _machineAdded(self, container_stack: ContainerInterface): + if not isinstance(container_stack, GlobalStack): return # Not our concern. - if definition_container.getMetaDataEntry("position") is not None: - return # This is an extruder definition. Not our concern. - definition_id = definition_container.getId() + definition_id = container_stack.definition.getId() if definition_id in self.machines: return # Already have this definition ID.