From 9c2fd1c9d421a4ffb1a60d8e6eb10a62dd45cf3a Mon Sep 17 00:00:00 2001 From: Tim Kuipers Date: Fri, 3 Jan 2020 15:13:24 +0100 Subject: [PATCH] automatically add shell thickness to stack and set to zero for infill meshes and remove when unmodified and we change to another mesh type --- .../PerObjectSettingsTool/PerObjectSettingsTool.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/plugins/PerObjectSettingsTool/PerObjectSettingsTool.py b/plugins/PerObjectSettingsTool/PerObjectSettingsTool.py index b2eb925a6d..8f2164261b 100644 --- a/plugins/PerObjectSettingsTool/PerObjectSettingsTool.py +++ b/plugins/PerObjectSettingsTool/PerObjectSettingsTool.py @@ -68,7 +68,8 @@ class PerObjectSettingsTool(Tool): ## Returns True when the mesh_type was changed, False when current mesh_type == mesh_type def setMeshType(self, mesh_type: str) -> bool: - if self.getMeshType() == mesh_type: + old_mesh_type = self.getMeshType() + if old_mesh_type == mesh_type: return False selected_object = Selection.getSelectedObject(0) @@ -94,6 +95,17 @@ class PerObjectSettingsTool(Tool): new_instance.resetState() # Ensure that the state is not seen as a user state. settings.addInstance(new_instance) + for property_key in ["top_bottom_thickness", "wall_thickness"]: + if mesh_type == "infill_mesh": + if not settings.getInstance(property_key): + definition = stack.getSettingDefinition(property_key) + new_instance = SettingInstance(definition, settings) + new_instance.setProperty("value", 0) + new_instance.resetState() # Ensure that the state is not seen as a user state. + settings.addInstance(new_instance) + elif old_mesh_type == "infill_mesh" and settings.getInstance(property_key) and settings.getProperty(property_key, "value") == 0: + settings.removeInstance(property_key) + self.propertyChanged.emit() return True