diff options
author | Arjen Hiemstra <ahiemstra@heimr.nl> | 2017-04-24 18:08:19 +0300 |
---|---|---|
committer | Arjen Hiemstra <ahiemstra@heimr.nl> | 2017-04-24 18:08:19 +0300 |
commit | b4c557679cdbc95b8ed9ee7ea357245328cb8ab0 (patch) | |
tree | dfd5fedeac75277aa0bf5a27bbc2d69d773d1b15 /cura/CuraActions.py | |
parent | 01f33d3f28accc19484bf93d2092075e7a069051 (diff) |
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
Diffstat (limited to 'cura/CuraActions.py')
-rw-r--r-- | cura/CuraActions.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/cura/CuraActions.py b/cura/CuraActions.py index 5c89232639..64db7c9372 100644 --- a/cura/CuraActions.py +++ b/cura/CuraActions.py @@ -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() |