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
This commit is contained in:
Kostas Karmas 2020-10-09 15:59:50 +02:00
parent 0922f03ca5
commit eedbcb6a2d
2 changed files with 4 additions and 4 deletions

View File

@ -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()

View File

@ -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()