From 274dc8d06c6cdfaabe4eaef65913ded382dd34d9 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 2 Oct 2020 11:21:57 +0200 Subject: [PATCH] Split up arrange This splits up the finding of new positions with the actual move. This is needed for when we want to place new nodes on model load. CURA-7440 --- cura/Arranging/Nest2DArrange.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/cura/Arranging/Nest2DArrange.py b/cura/Arranging/Nest2DArrange.py index 55c6f0675a..523f292adb 100644 --- a/cura/Arranging/Nest2DArrange.py +++ b/cura/Arranging/Nest2DArrange.py @@ -10,7 +10,7 @@ from UM.Operations.RotateOperation import RotateOperation from UM.Operations.TranslateOperation import TranslateOperation -def arrange(nodes_to_arrange, build_volume, fixed_nodes = None, factor = 10000) -> bool: +def findNodePlacement(nodes_to_arrange, build_volume, fixed_nodes = None, factor = 10000): machine_width = build_volume.getWidth() machine_depth = build_volume.getDepth() build_plate_bounding_box = Box(machine_width * factor, machine_depth * factor) @@ -61,6 +61,13 @@ def arrange(nodes_to_arrange, build_volume, fixed_nodes = None, factor = 10000) node_items = node_items[:-num_disallowed_areas_added] found_solution_for_all = num_bins == 1 + + return found_solution_for_all, node_items + + +def arrange(nodes_to_arrange, build_volume, fixed_nodes = None, factor = 10000) -> bool: + found_solution_for_all, node_items = findNodePlacement(nodes_to_arrange, build_volume, fixed_nodes, factor) + not_fit_count = 0 grouped_operation = GroupedOperation() for node, node_item in zip(nodes_to_arrange, node_items): @@ -78,4 +85,4 @@ def arrange(nodes_to_arrange, build_volume, fixed_nodes = None, factor = 10000) not_fit_count += 1 grouped_operation.push() - return found_solution_for_all \ No newline at end of file + return found_solution_for_all