From 111136cf493c7d2a567d68bfb9ceffe90f340453 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Kerbiriou?= Date: Thu, 1 Sep 2022 15:29:52 +0200 Subject: [PATCH 1/2] use automatic drop down setting from SceneNodeSettings --- cura/PlatformPhysics.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/cura/PlatformPhysics.py b/cura/PlatformPhysics.py index e054528c42..ebf885d609 100755 --- a/cura/PlatformPhysics.py +++ b/cura/PlatformPhysics.py @@ -10,6 +10,7 @@ from UM.Scene.Iterator.BreadthFirstIterator import BreadthFirstIterator from UM.Math.Vector import Vector from UM.Scene.Selection import Selection from UM.Scene.SceneNodeSettings import SceneNodeSettings +from UM.Util import parseBool from cura.Scene.ConvexHullDecorator import ConvexHullDecorator @@ -50,8 +51,13 @@ class PlatformPhysics: if not self._enabled: return + app_instance = Application.getInstance() + app_preferences = app_instance.getPreferences() + app_automatic_drop_down = str(app_preferences.getValue("physics/automatic_drop_down")) + app_automatic_push_free = app_preferences.getValue("physics/automatic_push_free") + root = self._controller.getScene().getRoot() - build_volume = Application.getInstance().getBuildVolume() + build_volume = app_instance.getBuildVolume() build_volume.updateNodeBoundaryCheck() # Keep a list of nodes that are moving. We use this so that we don't move two intersecting objects in the @@ -75,7 +81,7 @@ class PlatformPhysics: # Move it downwards if bottom is above platform move_vector = Vector() - if Application.getInstance().getPreferences().getValue("physics/automatic_drop_down") and not (node.getParent() and node.getParent().callDecoration("isGroup") or node.getParent() != root) and node.isEnabled(): #If an object is grouped, don't move it down + if parseBool(node.getSetting(SceneNodeSettings.AutoDropDown, app_automatic_drop_down)) and not (node.getParent() and node.getParent().callDecoration("isGroup") or node.getParent() != root) and node.isEnabled(): #If an object is grouped, don't move it down z_offset = node.callDecoration("getZOffset") if node.getDecorator(ZOffsetDecorator.ZOffsetDecorator) else 0 move_vector = move_vector.set(y = -bbox.bottom + z_offset) @@ -84,7 +90,7 @@ class PlatformPhysics: node.addDecorator(ConvexHullDecorator()) # only push away objects if this node is a printing mesh - if not node.callDecoration("isNonPrintingMesh") and Application.getInstance().getPreferences().getValue("physics/automatic_push_free"): + if not node.callDecoration("isNonPrintingMesh") and app_automatic_push_free: # Do not move locked nodes if node.getSetting(SceneNodeSettings.LockPosition): continue From 4b7f18c08ce985581800fa0152ce8f93eb745cb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Kerbiriou?= Date: Tue, 6 Sep 2022 17:59:54 +0200 Subject: [PATCH 2/2] SceneNode settings use native python types --- cura/CuraApplication.py | 2 +- cura/PlatformPhysics.py | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index f690456913..9f8ee0f4f0 100755 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -1445,7 +1445,7 @@ class CuraApplication(QtApplication): bounding_box = node.getBoundingBox() if bounding_box is None or bounding_box.width < self._volume.getBoundingBox().width or bounding_box.depth < self._volume.getBoundingBox().depth: # Arrange only the unlocked nodes and keep the locked ones in place - if UM.Util.parseBool(node.getSetting(SceneNodeSettings.LockPosition)): + if node.getSetting(SceneNodeSettings.LockPosition): locked_nodes.append(node) else: nodes_to_arrange.append(node) diff --git a/cura/PlatformPhysics.py b/cura/PlatformPhysics.py index ebf885d609..402b9fe250 100755 --- a/cura/PlatformPhysics.py +++ b/cura/PlatformPhysics.py @@ -10,7 +10,6 @@ from UM.Scene.Iterator.BreadthFirstIterator import BreadthFirstIterator from UM.Math.Vector import Vector from UM.Scene.Selection import Selection from UM.Scene.SceneNodeSettings import SceneNodeSettings -from UM.Util import parseBool from cura.Scene.ConvexHullDecorator import ConvexHullDecorator @@ -53,7 +52,7 @@ class PlatformPhysics: app_instance = Application.getInstance() app_preferences = app_instance.getPreferences() - app_automatic_drop_down = str(app_preferences.getValue("physics/automatic_drop_down")) + app_automatic_drop_down = app_preferences.getValue("physics/automatic_drop_down") app_automatic_push_free = app_preferences.getValue("physics/automatic_push_free") root = self._controller.getScene().getRoot() @@ -81,7 +80,7 @@ class PlatformPhysics: # Move it downwards if bottom is above platform move_vector = Vector() - if parseBool(node.getSetting(SceneNodeSettings.AutoDropDown, app_automatic_drop_down)) and not (node.getParent() and node.getParent().callDecoration("isGroup") or node.getParent() != root) and node.isEnabled(): #If an object is grouped, don't move it down + if node.getSetting(SceneNodeSettings.AutoDropDown, app_automatic_drop_down) and not (node.getParent() and node.getParent().callDecoration("isGroup") or node.getParent() != root) and node.isEnabled(): #If an object is grouped, don't move it down z_offset = node.callDecoration("getZOffset") if node.getDecorator(ZOffsetDecorator.ZOffsetDecorator) else 0 move_vector = move_vector.set(y = -bbox.bottom + z_offset)