From eedbcb6a2d7fd1ed2cb1cb656a8e47ec380bfcbf Mon Sep 17 00:00:00 2001 From: Kostas Karmas Date: Fri, 9 Oct 2020 15:59:50 +0200 Subject: [PATCH] Fix z position of objects that end outside the buildplate When multiplying objects or inserting objects in the scene that do not fit in the buildplate, those objects would correctly end up outside the buildplate, but their Z position would be aligned at the absolute Z=0 of the buildplate. This commit fixes that by compensating in the z-axis, properly moving the object outside the buildplate in the correct z-position so that it's bottom is aligned with the original object. CURA-7440 --- cura/Arranging/Nest2DArrange.py | 3 ++- cura/MultiplyObjectsJob.py | 5 ++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cura/Arranging/Nest2DArrange.py b/cura/Arranging/Nest2DArrange.py index 36d391e8a2..8e87228ded 100644 --- a/cura/Arranging/Nest2DArrange.py +++ b/cura/Arranging/Nest2DArrange.py @@ -112,6 +112,7 @@ def arrange(nodes_to_arrange: List["SceneNode"], build_volume: "BuildVolume", fi not_fit_count = 0 grouped_operation = GroupedOperation() for node, node_item in zip(nodes_to_arrange, node_items): + if node_item.binId() == 0: # We found a spot for it rotation_matrix = Matrix() @@ -122,7 +123,7 @@ def arrange(nodes_to_arrange: List["SceneNode"], build_volume: "BuildVolume", fi else: # We didn't find a spot grouped_operation.addOperation( - TranslateOperation(node, Vector(200, 0, -not_fit_count * 20), set_position=True)) + TranslateOperation(node, Vector(200, node.getWorldPosition().y, -not_fit_count * 20), set_position = True)) not_fit_count += 1 grouped_operation.push() diff --git a/cura/MultiplyObjectsJob.py b/cura/MultiplyObjectsJob.py index b54f7bcdce..24c74f655c 100644 --- a/cura/MultiplyObjectsJob.py +++ b/cura/MultiplyObjectsJob.py @@ -88,11 +88,10 @@ class MultiplyObjectsJob(Job): operation.addOperation(RotateOperation(new_node, Quaternion.fromMatrix(rotation_matrix))) operation.addOperation( TranslateOperation(new_node, Vector(node_item.translation().x() / factor, 0, - node_item.translation().y() / factor))) + node_item.translation().y() / factor))) else: # We didn't find a spot - operation.addOperation( - TranslateOperation(new_node, Vector(200, 0, -not_fit_count * 20), set_position=True)) + operation.addOperation(TranslateOperation(new_node, Vector(200, new_node.getWorldPosition().y, -not_fit_count * 20), set_position = True)) not_fit_count += 1 operation.push()