Browse Source

Override all settings that might influence infill mesh shells to 0

If the user had specialised settings fixing the number of walls or skin layers to an integer number, this fixed value would get copied over from the extruder settings, causing infill meshes to have walls by default.
This is unintuitive. We want infill meshes to behave like it's only infill by default. So remove all of those overrides so that only infill gets printed there, by default.

The user may still change the number of walls or skin layers or their parent settings. But by default it should now behave like infill within infill, regardless of the user's setting overrides.

Fixes issue CURA-8393 and fixes #9815.
Ghostkeeper 3 years ago
parent
commit
6f6d8d0f93
1 changed files with 14 additions and 7 deletions
  1. 14 7
      plugins/PerObjectSettingsTool/PerObjectSettingsTool.py

+ 14 - 7
plugins/PerObjectSettingsTool/PerObjectSettingsTool.py

@@ -1,4 +1,4 @@
-# Copyright (c) 2020 Ultimaker B.V.
+# Copyright (c) 2021 Ultimaker B.V.
 # Cura is released under the terms of the LGPLv3 or higher.
 
 from UM.Logger import Logger
@@ -103,20 +103,27 @@ 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", "wall_line_count"]:
+        # Override some settings to ensure that the infill mesh by default adds no skin or walls. Or remove them if not an infill mesh.
+        specialized_settings = {
+            "top_bottom_thickness": 0,
+            "top_thickness": "=top_bottom_thickness",
+            "bottom_thickness": "=top_bottom_thickness",
+            "top_layers": "=0 if infill_sparse_density == 100 else math.ceil(round(top_thickness / resolveOrValue('layer_height'), 4))",
+            "bottom_layers": "=0 if infill_sparse_density == 100 else math.ceil(round(bottom_thickness / resolveOrValue('layer_height'), 4))",
+            "wall_thickness": 0,
+            "wall_line_count": "=max(1, round((wall_thickness - wall_line_width_0) / wall_line_width_x) + 1) if wall_thickness != 0 else 0"
+        }
+        for property_key in specialized_settings:
             if mesh_type == "infill_mesh":
                 if settings.getInstance(property_key) is None:
                     definition = stack.getSettingDefinition(property_key)
                     new_instance = SettingInstance(definition, settings)
-                    # We just want the wall_line count to be there in case it was overriden in the global stack.
-                    # as such, we don't need to set a value.
-                    if property_key != "wall_line_count":
-                        new_instance.setProperty("value", 0)
+                    new_instance.setProperty("value", specialized_settings[property_key])
                     new_instance.resetState()  # Ensure that the state is not seen as a user state.
                     settings.addInstance(new_instance)
                     settings_visibility_changed = True
 
-            elif old_mesh_type == "infill_mesh" and settings.getInstance(property_key) and (settings.getProperty(property_key, "value") == 0 or property_key == "wall_line_count"):
+            elif old_mesh_type == "infill_mesh" and settings.getInstance(property_key) and property_key in specialized_settings:
                 settings.removeInstance(property_key)
                 settings_visibility_changed = True