mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-23 14:44:13 -06: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
1 changed files with 23 additions and 0 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue