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

and remove when unmodified and we change to another mesh type
This commit is contained in:
Tim Kuipers 2020-01-03 15:13:24 +01:00
parent eb1ae9f18d
commit 9c2fd1c9d4

View file

@ -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