Browse Source

automatically add shell thickness to stack and set to zero for infill meshes

and remove when unmodified and we change to another mesh type
Tim Kuipers 5 years ago
parent
commit
9c2fd1c9d4
1 changed files with 13 additions and 1 deletions
  1. 13 1
      plugins/PerObjectSettingsTool/PerObjectSettingsTool.py

+ 13 - 1
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
     ## Returns True when the mesh_type was changed, False when current mesh_type == mesh_type
     def setMeshType(self, mesh_type: str) -> bool:
     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
             return False
 
 
         selected_object = Selection.getSelectedObject(0)
         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.
                     new_instance.resetState()  # Ensure that the state is not seen as a user state.
                     settings.addInstance(new_instance)
                     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()
         self.propertyChanged.emit()
         return True
         return True