mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-13 16:18:58 +08:00
Use global_stack.extruders instead of ExtruderManager.extruderIds
CURA-5168 We want to remove ExtruderManager eventually, and keeping two separate pieces of data can cause it to be out of sync.
This commit is contained in:
parent
79daf3706b
commit
90d2c29fb4
@ -259,8 +259,9 @@ class ExtruderManager(QObject):
|
|||||||
#
|
#
|
||||||
# \return A list of extruder stacks.
|
# \return A list of extruder stacks.
|
||||||
def getUsedExtruderStacks(self) -> List["ContainerStack"]:
|
def getUsedExtruderStacks(self) -> List["ContainerStack"]:
|
||||||
global_stack = self._application.getGlobalContainerStack()
|
machine_manager = self._application.getMachineManager()
|
||||||
container_registry = ContainerRegistry.getInstance()
|
container_registry = ContainerRegistry.getInstance()
|
||||||
|
global_stack = machine_manager.activeMachine
|
||||||
|
|
||||||
used_extruder_stack_ids = set()
|
used_extruder_stack_ids = set()
|
||||||
|
|
||||||
@ -269,11 +270,7 @@ class ExtruderManager(QObject):
|
|||||||
support_bottom_enabled = False
|
support_bottom_enabled = False
|
||||||
support_roof_enabled = False
|
support_roof_enabled = False
|
||||||
|
|
||||||
scene_root = Application.getInstance().getController().getScene().getRoot()
|
scene_root = self._application.getController().getScene().getRoot()
|
||||||
|
|
||||||
# If no extruders are registered in the extruder manager yet, return an empty array
|
|
||||||
if len(self.extruderIds) == 0:
|
|
||||||
return []
|
|
||||||
|
|
||||||
# Get the extruders of all printable meshes in the scene
|
# Get the extruders of all printable meshes in the scene
|
||||||
meshes = [node for node in DepthFirstIterator(scene_root) if isinstance(node, SceneNode) and node.isSelectable()]
|
meshes = [node for node in DepthFirstIterator(scene_root) if isinstance(node, SceneNode) and node.isSelectable()]
|
||||||
@ -281,7 +278,7 @@ class ExtruderManager(QObject):
|
|||||||
extruder_stack_id = mesh.callDecoration("getActiveExtruder")
|
extruder_stack_id = mesh.callDecoration("getActiveExtruder")
|
||||||
if not extruder_stack_id:
|
if not extruder_stack_id:
|
||||||
# No per-object settings for this node
|
# No per-object settings for this node
|
||||||
extruder_stack_id = self.extruderIds["0"]
|
extruder_stack_id = global_stack.extruders["0"].getId()
|
||||||
used_extruder_stack_ids.add(extruder_stack_id)
|
used_extruder_stack_ids.add(extruder_stack_id)
|
||||||
|
|
||||||
# Get whether any of them use support.
|
# Get whether any of them use support.
|
||||||
@ -305,23 +302,23 @@ class ExtruderManager(QObject):
|
|||||||
extruder_nr = int(global_stack.getProperty(extruder_nr_feature_name, "value"))
|
extruder_nr = int(global_stack.getProperty(extruder_nr_feature_name, "value"))
|
||||||
if extruder_nr == -1:
|
if extruder_nr == -1:
|
||||||
continue
|
continue
|
||||||
used_extruder_stack_ids.add(self.extruderIds[str(extruder_nr)])
|
used_extruder_stack_ids.add(global_stack.extruders[str(extruder_nr)].getId())
|
||||||
|
|
||||||
# Check support extruders
|
# Check support extruders
|
||||||
if support_enabled:
|
if support_enabled:
|
||||||
used_extruder_stack_ids.add(self.extruderIds[self.extruderValueWithDefault(str(global_stack.getProperty("support_infill_extruder_nr", "value")))])
|
used_extruder_stack_ids.add(global_stack.extruders[self.extruderValueWithDefault(str(global_stack.getProperty("support_infill_extruder_nr", "value")))].getId())
|
||||||
used_extruder_stack_ids.add(self.extruderIds[self.extruderValueWithDefault(str(global_stack.getProperty("support_extruder_nr_layer_0", "value")))])
|
used_extruder_stack_ids.add(global_stack.extruders[self.extruderValueWithDefault(str(global_stack.getProperty("support_extruder_nr_layer_0", "value")))].getId())
|
||||||
if support_bottom_enabled:
|
if support_bottom_enabled:
|
||||||
used_extruder_stack_ids.add(self.extruderIds[self.extruderValueWithDefault(str(global_stack.getProperty("support_bottom_extruder_nr", "value")))])
|
used_extruder_stack_ids.add(global_stack.extruders[self.extruderValueWithDefault(str(global_stack.getProperty("support_bottom_extruder_nr", "value")))].getId())
|
||||||
if support_roof_enabled:
|
if support_roof_enabled:
|
||||||
used_extruder_stack_ids.add(self.extruderIds[self.extruderValueWithDefault(str(global_stack.getProperty("support_roof_extruder_nr", "value")))])
|
used_extruder_stack_ids.add(global_stack.extruders[self.extruderValueWithDefault(str(global_stack.getProperty("support_roof_extruder_nr", "value")))].getId())
|
||||||
|
|
||||||
# The platform adhesion extruder. Not used if using none.
|
# The platform adhesion extruder. Not used if using none.
|
||||||
if global_stack.getProperty("adhesion_type", "value") != "none":
|
if global_stack.getProperty("adhesion_type", "value") != "none":
|
||||||
extruder_nr = str(global_stack.getProperty("adhesion_extruder_nr", "value"))
|
extruder_nr = str(global_stack.getProperty("adhesion_extruder_nr", "value"))
|
||||||
if extruder_nr == "-1":
|
if extruder_nr == "-1":
|
||||||
extruder_nr = Application.getInstance().getMachineManager().defaultExtruderPosition
|
extruder_nr = Application.getInstance().getMachineManager().defaultExtruderPosition
|
||||||
used_extruder_stack_ids.add(self.extruderIds[extruder_nr])
|
used_extruder_stack_ids.add(global_stack.extruders[extruder_nr].getId())
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return [container_registry.findContainerStacks(id = stack_id)[0] for stack_id in used_extruder_stack_ids]
|
return [container_registry.findContainerStacks(id = stack_id)[0] for stack_id in used_extruder_stack_ids]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user