Skip to content

Commit

Permalink
Add new nominal_layer_height setting, and make UI use it.
Browse files Browse the repository at this point in the history
  • Loading branch information
Frederic98 committed Jan 9, 2025
1 parent 5ccb96e commit 55ed9eb
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 32 deletions.
10 changes: 5 additions & 5 deletions cura/Machines/Models/MachineModelUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@ def fetchLayerHeight(quality_group: "QualityGroup") -> float:
from cura.CuraApplication import CuraApplication
global_stack = CuraApplication.getInstance().getMachineManager().activeMachine

default_layer_height = global_stack.definition.getProperty("layer_height", "value")
default_layer_height = global_stack.definition.getProperty("nominal_layer_height", "value")

# Get layer_height from the quality profile for the GlobalStack
if quality_group.node_for_global is None:
return float(default_layer_height)
container = quality_group.node_for_global.container

layer_height = default_layer_height
if container and container.hasProperty("layer_height", "value"):
layer_height = container.getProperty("layer_height", "value")
if container and container.hasProperty("nominal_layer_height", "value"):
layer_height = container.getProperty("nominal_layer_height", "value")
else:
# Look for layer_height in the GlobalStack from material -> definition
container = global_stack.definition
if container and container.hasProperty("layer_height", "value"):
layer_height = container.getProperty("layer_height", "value")
if container and container.hasProperty("nominal_layer_height", "value"):
layer_height = container.getProperty("nominal_layer_height", "value")

if isinstance(layer_height, SettingFunction):
layer_height = layer_height(global_stack)
Expand Down
2 changes: 1 addition & 1 deletion cura/Machines/Models/QualityProfilesDropDownMenuModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def _update(self):
return

if not self._layer_height_unit:
unit = global_stack.definition.getProperty("layer_height", "unit")
unit = global_stack.definition.getProperty("nominal_layer_height", "unit")
if not unit:
unit = ""
self._layer_height_unit = unit
Expand Down
2 changes: 1 addition & 1 deletion cura/Settings/MachineManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ def activeQualityLayerHeight(self) -> float:

if not self._global_container_stack:
return 0
value = self._global_container_stack.getRawProperty("layer_height", "value", skip_until_container = self._global_container_stack.qualityChanges.getId())
value = self._global_container_stack.getRawProperty("nominal_layer_height", "value", skip_until_container = self._global_container_stack.qualityChanges.getId())
if isinstance(value, SettingFunction):
value = value(self._global_container_stack)
return value
Expand Down
53 changes: 35 additions & 18 deletions resources/definitions/fdmprinter.def.json
Original file line number Diff line number Diff line change
Expand Up @@ -798,32 +798,49 @@
"description": "All settings that influence the resolution of the print. These settings have a large impact on the quality (and print time)",
"children":
{
"layer_height":
"nominal_layer_height":
{
"label": "Layer Height",
"description": "The height of each layer in mm. Higher values produce faster prints in lower resolution, lower values produce slower prints in higher resolution.",
"label": "Nominal Layer Height",
"description": "The nominal layer height of the final printed part.",
"unit": "mm",
"type": "float",
"default_value": 0.1,
"minimum_value": "0.001",
"minimum_value_warning": "0.04",
"maximum_value_warning": "0.8 * min(extruderValues('machine_nozzle_size'))",
"settable_per_mesh": false,
"settable_per_extruder": false
},
"layer_height_0":
{
"label": "Initial Layer Height",
"description": "The height of the initial layer in mm. A thicker initial layer makes adhesion to the build plate easier.",
"unit": "mm",
"type": "float",
"default_value": 0.3,
"resolve": "min(extruderValues('layer_height_0'))",
"minimum_value": "0.001",
"minimum_value_warning": "0.1",
"maximum_value_warning": "0.8 * min(extruderValues('machine_nozzle_size'))",
"settable_per_mesh": false,
"settable_per_extruder": false
"settable_per_extruder": false,
"children":
{
"layer_height":
{
"label": "Layer Height",
"description": "The height of each layer in mm. Higher values produce faster prints in lower resolution, lower values produce slower prints in higher resolution.",
"unit": "mm",
"type": "float",
"default_value": 0.1,
"value": "nominal_layer_height",
"minimum_value": "0.001",
"minimum_value_warning": "0.04",
"maximum_value_warning": "0.8 * min(extruderValues('machine_nozzle_size'))",
"settable_per_mesh": false,
"settable_per_extruder": false
},
"layer_height_0":
{
"label": "Initial Layer Height",
"description": "The height of the initial layer in mm. A thicker initial layer makes adhesion to the build plate easier.",
"unit": "mm",
"type": "float",
"default_value": 0.3,
"resolve": "min(extruderValues('layer_height_0'))",
"minimum_value": "0.001",
"minimum_value_warning": "0.1",
"maximum_value_warning": "0.8 * min(extruderValues('machine_nozzle_size'))",
"settable_per_mesh": false,
"settable_per_extruder": false
}
}
},
"line_width":
{
Expand Down
3 changes: 2 additions & 1 deletion resources/definitions/ultimaker_factor4.def.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@
"value": "5"
},
"jerk_travel_enabled": { "value": "True" },
"layer_height": { "value": "min(min(extruderValues('machine_nozzle_size')) / 2, 0.2)" },
"nominal_layer_height": { "value": "min(min(extruderValues('machine_nozzle_size')) / 2, 0.2)" },
"layer_height": { "value": "round(nominal_layer_height * material_shrinkage_percentage_z / 100, 5)" },
"machine_acceleration": { "default_value": 3000 },
"machine_depth": { "default_value": 240 },
"machine_end_gcode": { "default_value": "" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ RowLayout
{
id: layerHeight
containerStack: Cura.MachineManager.activeStack
key: "layer_height"
key: "nominal_layer_height"
watchedProperties: ["value"]
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ type = quality
weight = -2

[values]
layer_height = =round(0.2 * material_shrinkage_percentage_z / 100, 5)
nominal_layer_height = 0.2

Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ type = quality
weight = -1

[values]
layer_height = =round(0.15 * material_shrinkage_percentage_z / 100, 5)
nominal_layer_height = 0.15

Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ type = quality
weight = 0

[values]
layer_height = =round(0.1 * material_shrinkage_percentage_z / 100, 5)
nominal_layer_height = 0.1

Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ type = quality
weight = -4

[values]
layer_height = =round(0.4 * material_shrinkage_percentage_z / 100, 5)
nominal_layer_height = 0.4

Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ type = quality
weight = -3

[values]
layer_height = =round(0.3 * material_shrinkage_percentage_z / 100, 5)
nominal_layer_height = 0.3

0 comments on commit 55ed9eb

Please sign in to comment.