diff options
author | Jaime van Kessel <nallath@gmail.com> | 2021-10-04 16:52:08 +0300 |
---|---|---|
committer | Jaime van Kessel <nallath@gmail.com> | 2021-10-04 16:52:08 +0300 |
commit | 44eb3201a9dfad76a62dfff18fad628d39464e6e (patch) | |
tree | 16fe8e8eac5d572e16693640880ad0e0f546715a /cura/MultiplyObjectsJob.py | |
parent | f749bbef4604df41e72cd4a2c67db755cde03a6b (diff) |
Fix duplicating / multiplicating support blockers
CURA-7851
Diffstat (limited to 'cura/MultiplyObjectsJob.py')
-rw-r--r-- | cura/MultiplyObjectsJob.py | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/cura/MultiplyObjectsJob.py b/cura/MultiplyObjectsJob.py index 4c1caf137c..e7890ce2eb 100644 --- a/cura/MultiplyObjectsJob.py +++ b/cura/MultiplyObjectsJob.py @@ -7,10 +7,12 @@ from typing import List from UM.Application import Application from UM.Job import Job from UM.Message import Message +from UM.Operations.AddSceneNodeOperation import AddSceneNodeOperation +from UM.Operations.GroupedOperation import GroupedOperation from UM.Scene.Iterator.DepthFirstIterator import DepthFirstIterator from UM.Scene.SceneNode import SceneNode from UM.i18n import i18nCatalog -from cura.Arranging.Nest2DArrange import arrange +from cura.Arranging.Nest2DArrange import arrange, createGroupOperationForArrange i18n_catalog = i18nCatalog("cura") @@ -43,11 +45,11 @@ class MultiplyObjectsJob(Job): # Only count sliceable objects if node_.callDecoration("isSliceable"): fixed_nodes.append(node_) - + nodes_to_add_without_arrange = [] for node in self._objects: # If object is part of a group, multiply group current_node = node - while current_node.getParent() and (current_node.getParent().callDecoration("isGroup") or current_node.getParent().callDecoration("isSliceable")): + while current_node.getParent() and current_node.getParent().callDecoration("isGroup"): current_node = current_node.getParent() if current_node in processed_nodes: @@ -56,19 +58,33 @@ class MultiplyObjectsJob(Job): for _ in range(self._count): new_node = copy.deepcopy(node) - # Same build plate build_plate_number = current_node.callDecoration("getBuildPlateNumber") new_node.callDecoration("setBuildPlateNumber", build_plate_number) for child in new_node.getChildren(): child.callDecoration("setBuildPlateNumber", build_plate_number) - - nodes.append(new_node) + if not current_node.getParent().callDecoration("isSliceable"): + nodes.append(new_node) + else: + # The node we're trying to place has another node that is sliceable as a parent. + # As such, we shouldn't arrange it (but it should be added to the scene!) + nodes_to_add_without_arrange.append(new_node) + new_node.setParent(current_node.getParent()) found_solution_for_all = True if nodes: - found_solution_for_all = arrange(nodes, Application.getInstance().getBuildVolume(), fixed_nodes, - factor = 10000, add_new_nodes_in_scene = True) + group_operation, not_fit_count = createGroupOperationForArrange(nodes, + Application.getInstance().getBuildVolume(), + fixed_nodes, + factor=10000, add_new_nodes_in_scene=True) + else: + group_operation = GroupedOperation() + + if nodes_to_add_without_arrange: + for nested_node in nodes_to_add_without_arrange: + group_operation.addOperation(AddSceneNodeOperation(nested_node, nested_node.getParent())) + + group_operation.redo() status_message.hide() if not found_solution_for_all: |