From 733447a2dd16ea4b036a34543e5ba40dc2d61ef0 Mon Sep 17 00:00:00 2001
From: "p.kuiper"
Date: Fri, 1 Apr 2022 13:00:41 +0200
Subject: [PATCH] Removed the settings: "material_shrinkage_percentage" and
update code that was using this parameter.
material_shrinkage_percentage_xy and material_shrinkage_percentage_z cannot depend on material_shrinkage_percentage otherwise their resolve function will not execute properly.
I noticed that the shrinkage factors do not get the correct value if a wrong nozzle is chosen for a material. However, in that case the slicer will also not slice, so in practice this is not an issue
Relates to PP-77
---
cura/Scene/ConvexHullDecorator.py | 2 +-
plugins/ModelChecker/ModelChecker.py | 2 +-
resources/definitions/fdmprinter.def.json | 58 ++++++++---------------
resources/setting_visibility/expert.cfg | 6 +--
4 files changed, 24 insertions(+), 44 deletions(-)
diff --git a/cura/Scene/ConvexHullDecorator.py b/cura/Scene/ConvexHullDecorator.py
index 36697b7c57..4545a49aa0 100644
--- a/cura/Scene/ConvexHullDecorator.py
+++ b/cura/Scene/ConvexHullDecorator.py
@@ -383,7 +383,7 @@ class ConvexHullDecorator(SceneNodeDecorator):
# Shrinkage compensation.
if not self._global_stack: # Should never happen.
return convex_hull
- scale_factor = self._global_stack.getProperty("material_shrinkage_percentage", "value") / 100.0
+ scale_factor = self._global_stack.getProperty("material_shrinkage_percentage_xy", "value") / 100.0
result = convex_hull
if scale_factor != 1.0 and not self.getNode().callDecoration("isGroup"):
center = None
diff --git a/plugins/ModelChecker/ModelChecker.py b/plugins/ModelChecker/ModelChecker.py
index 321ce8d007..6d039545d7 100644
--- a/plugins/ModelChecker/ModelChecker.py
+++ b/plugins/ModelChecker/ModelChecker.py
@@ -139,4 +139,4 @@ class ModelChecker(QObject, Extension):
global_container_stack = Application.getInstance().getGlobalContainerStack()
if global_container_stack is None:
return 100
- return global_container_stack.getProperty("material_shrinkage_percentage", "value")
+ return max(global_container_stack.getProperty("material_shrinkage_percentage_xy", "value"), global_container_stack.getProperty("material_shrinkage_percentage_z", "value"))
diff --git a/resources/definitions/fdmprinter.def.json b/resources/definitions/fdmprinter.def.json
index 1709330e24..7e20b9f732 100644
--- a/resources/definitions/fdmprinter.def.json
+++ b/resources/definitions/fdmprinter.def.json
@@ -2527,10 +2527,10 @@
"settable_per_mesh": false,
"settable_per_extruder": true
},
- "material_shrinkage_percentage":
+ "material_shrinkage_percentage_xy":
{
- "label": "Scaling Factor Shrinkage Compensation",
- "description": "To compensate for the shrinkage of the material as it cools down, the model will be scaled with this factor.",
+ "label": "Horizontal Scaling Factor Shrinkage Compensation",
+ "description": "To compensate for the shrinkage of the material as it cools down, the model will be scaled with this factor in the XY-direction (horizontally).",
"unit": "%",
"type": "float",
"default_value": null,
@@ -2540,42 +2540,22 @@
"maximum_value_warning": "120",
"settable_per_mesh": false,
"settable_per_extruder": false,
- "resolve": "100 if sum(1 if s != None else 0 for s in extruderValues('material_shrinkage_percentage')) == 0 else sum(s if s != None else 0 for s in extruderValues('material_shrinkage_percentage'))/sum(1 if s != None else 0 for s in extruderValues('material_shrinkage_percentage'))",
- "children":
- {
- "material_shrinkage_percentage_xy":
- {
- "label": "Horizontal Scaling Factor Shrinkage Compensation",
- "description": "To compensate for the shrinkage of the material as it cools down, the model will be scaled with this factor in the XY-direction (horizontally).",
- "unit": "%",
- "type": "float",
- "default_value": null,
- "enabled": true,
- "minimum_value": "0.001",
- "minimum_value_warning": "100",
- "maximum_value_warning": "120",
- "settable_per_mesh": false,
- "settable_per_extruder": false,
- "resolve": "100 if sum(1 if s != None else 0 for s in extruderValues('material_shrinkage_percentage_xy')) == 0 else sum(s if s != None else 0 for s in extruderValues('material_shrinkage_percentage_xy'))/sum(1 if s != None else 0 for s in extruderValues('material_shrinkage_percentage_xy'))",
- "value": "material_shrinkage_percentage"
- },
- "material_shrinkage_percentage_z":
- {
- "label": "Vertical Scaling Factor Shrinkage Compensation",
- "description": "To compensate for the shrinkage of the material as it cools down, the model will be scaled with this factor in the Z-direction (vertically).",
- "unit": "%",
- "type": "float",
- "default_value": null,
- "enabled": true,
- "minimum_value": "0.001",
- "minimum_value_warning": "100",
- "maximum_value_warning": "120",
- "settable_per_mesh": false,
- "settable_per_extruder": false,
- "resolve": "100 if sum(1 if s != None else 0 for s in extruderValues('material_shrinkage_percentage_z')) == 0 else sum(s if s != None else 0 for s in extruderValues('material_shrinkage_percentage_z'))/sum(1 if s != None else 0 for s in extruderValues('material_shrinkage_percentage_z'))",
- "value": "material_shrinkage_percentage"
- }
- }
+ "resolve": "100 if sum(1 if s != None else 0 for s in extruderValues('material_shrinkage_percentage_xy')) == 0 else sum(s if s != None else 0 for s in extruderValues('material_shrinkage_percentage_xy'))/sum(1 if s != None else 0 for s in extruderValues('material_shrinkage_percentage_xy'))"
+ },
+ "material_shrinkage_percentage_z":
+ {
+ "label": "Vertical Scaling Factor Shrinkage Compensation",
+ "description": "To compensate for the shrinkage of the material as it cools down, the model will be scaled with this factor in the Z-direction (vertically).",
+ "unit": "%",
+ "type": "float",
+ "default_value": null,
+ "enabled": true,
+ "minimum_value": "0.001",
+ "minimum_value_warning": "100",
+ "maximum_value_warning": "120",
+ "settable_per_mesh": false,
+ "settable_per_extruder": false,
+ "resolve": "100 if sum(1 if s != None else 0 for s in extruderValues('material_shrinkage_percentage_z')) == 0 else sum(s if s != None else 0 for s in extruderValues('material_shrinkage_percentage_z'))/sum(1 if s != None else 0 for s in extruderValues('material_shrinkage_percentage_z'))"
},
"material_crystallinity":
{
diff --git a/resources/setting_visibility/expert.cfg b/resources/setting_visibility/expert.cfg
index 3318329b2f..50154a168c 100644
--- a/resources/setting_visibility/expert.cfg
+++ b/resources/setting_visibility/expert.cfg
@@ -117,6 +117,8 @@ material_bed_temperature
material_bed_temperature_layer_0
material_adhesion_tendency
material_surface_energy
+material_shrinkage_percentage_xy
+material_shrinkage_percentage_z
material_flow
wall_material_flow
wall_0_material_flow
@@ -133,9 +135,7 @@ prime_tower_flow
material_flow_layer_0
material_standby_temperature
material_alternate_walls
-material_shrinkage_percentage
-material_shrinkage_percentage_xy
-material_shrinkage_percentage_z
+
[speed]
speed_print