From 10af3ee5ab7231bfd29df4b73eb163fad3d9e566 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Thu, 22 Sep 2016 15:16:39 +0200 Subject: [PATCH 1/2] More defensive coding to prevent division by zero CURA-2443 --- cura/CuraApplication.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index d7e0f1d374..43c11c26f0 100644 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -817,7 +817,7 @@ class CuraApplication(QtApplication): # Compute the center of the objects when their origins are aligned. object_centers = [node.getMeshData().getCenterPosition().scale(node.getScale()) for node in group_node.getChildren() if node.getMeshData()] - if object_centers: + if object_centers and len(object_centers) > 0: middle_x = sum([v.x for v in object_centers]) / len(object_centers) middle_y = sum([v.y for v in object_centers]) / len(object_centers) middle_z = sum([v.z for v in object_centers]) / len(object_centers) From 15792b8f091d800194a1c6b512dcb663d5ea817f Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Thu, 22 Sep 2016 15:33:17 +0200 Subject: [PATCH 2/2] Code style: Spaces around binary operators Also the equal-sign in key-word arguments, though that goes against PEP8, but that's in our code style documentation. Contributes to issue CURA-2319. --- .../PerObjectSettingVisibilityHandler.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/PerObjectSettingsTool/PerObjectSettingVisibilityHandler.py b/plugins/PerObjectSettingsTool/PerObjectSettingVisibilityHandler.py index 1396a02b13..6810ab82aa 100644 --- a/plugins/PerObjectSettingsTool/PerObjectSettingVisibilityHandler.py +++ b/plugins/PerObjectSettingsTool/PerObjectSettingVisibilityHandler.py @@ -72,9 +72,9 @@ class PerObjectSettingVisibilityHandler(UM.Settings.Models.SettingVisibilityHand # Use the found stack number to get the right stack to copy the value from. if stack_nr in ExtruderManager.getInstance().extruderIds: - stack = UM.Settings.ContainerRegistry.getInstance().findContainerStacks(id=ExtruderManager.getInstance().extruderIds[stack_nr])[0] + stack = UM.Settings.ContainerRegistry.getInstance().findContainerStacks(id = ExtruderManager.getInstance().extruderIds[stack_nr])[0] - # Use the raw property to set the value (so the intheritance doesn't break) + # Use the raw property to set the value (so the inheritance doesn't break) if stack is not None: new_instance.setProperty("value", stack.getRawProperty(item, "value")) else: