mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-12 20:19:13 +08:00
Change the selected extruder for all child nodes of a group
Instead of setting the extruder for the group node, go through all children and set their extruders instead. Fixes extruder selection on groups. Contributes to CURA-3609
This commit is contained in:
parent
01f33d3f28
commit
b4c557679c
@ -9,6 +9,7 @@ from UM.Event import CallFunctionEvent
|
||||
from UM.Application import Application
|
||||
from UM.Math.Vector import Vector
|
||||
from UM.Scene.Selection import Selection
|
||||
from UM.Scene.Iterator.BreadthFirstIterator import BreadthFirstIterator
|
||||
from UM.Operations.GroupedOperation import GroupedOperation
|
||||
from UM.Operations.RemoveSceneNodeOperation import RemoveSceneNodeOperation
|
||||
from UM.Operations.SetTransformOperation import SetTransformOperation
|
||||
@ -81,9 +82,31 @@ class CuraActions(QObject):
|
||||
@pyqtSlot(str)
|
||||
def setExtruderForSelection(self, extruder_id: str) -> None:
|
||||
operation = GroupedOperation()
|
||||
|
||||
nodes_to_change = []
|
||||
for node in Selection.getAllSelectedObjects():
|
||||
# Do not change any nodes that already have the right extruder set.
|
||||
if node.callDecoration("getActiveExtruder") == extruder_id:
|
||||
continue
|
||||
|
||||
# If the node is a group, apply the active extruder to all children of the group.
|
||||
if node.callDecoration("isGroup"):
|
||||
for grouped_node in BreadthFirstIterator(node):
|
||||
if grouped_node.callDecoration("getActiveExtruder") == extruder_id:
|
||||
continue
|
||||
|
||||
if grouped_node.callDecoration("isGroup"):
|
||||
continue
|
||||
|
||||
nodes_to_change.append(grouped_node)
|
||||
continue
|
||||
|
||||
nodes_to_change.append(node)
|
||||
|
||||
if not nodes_to_change:
|
||||
return
|
||||
|
||||
for node in nodes_to_change:
|
||||
operation.addOperation(SetObjectExtruderOperation(node, extruder_id))
|
||||
operation.push()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user