From 0a8ef5162e1261ab839531bd4804c0c8eeaaf52f Mon Sep 17 00:00:00 2001
From: "p.kuiper"
Date: Wed, 6 Apr 2022 13:28:55 +0200
Subject: [PATCH] Removed the rather hacky implementation of the shrinkage
factor averaging. Issues with dual extrusion were the second extruder is not
used should solved in a different way.
Relates to PP-77
---
cura/Scene/ConvexHullDecorator.py | 2 +-
plugins/ModelChecker/ModelChecker.py | 2 +-
resources/definitions/fdmprinter.def.json | 60 +++++++++++++++--------
resources/setting_visibility/expert.cfg | 1 +
4 files changed, 43 insertions(+), 22 deletions(-)
diff --git a/cura/Scene/ConvexHullDecorator.py b/cura/Scene/ConvexHullDecorator.py
index 4545a49aa0..36697b7c57 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_xy", "value") / 100.0
+ scale_factor = self._global_stack.getProperty("material_shrinkage_percentage", "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 6d039545d7..321ce8d007 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 max(global_container_stack.getProperty("material_shrinkage_percentage_xy", "value"), global_container_stack.getProperty("material_shrinkage_percentage_z", "value"))
+ return global_container_stack.getProperty("material_shrinkage_percentage", "value")
diff --git a/resources/definitions/fdmprinter.def.json b/resources/definitions/fdmprinter.def.json
index 7e20b9f732..58150f7b0d 100644
--- a/resources/definitions/fdmprinter.def.json
+++ b/resources/definitions/fdmprinter.def.json
@@ -2527,35 +2527,55 @@
"settable_per_mesh": false,
"settable_per_extruder": true
},
- "material_shrinkage_percentage_xy":
+ "material_shrinkage_percentage":
{
- "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).",
+ "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.",
"unit": "%",
"type": "float",
- "default_value": null,
+ "default_value": 100.0,
"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'))"
- },
- "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'))"
+ "resolve": "sum(extruderValues(\"material_shrinkage_percentage\")) / len(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": 100.0,
+ "enabled": true,
+ "minimum_value": "0.001",
+ "minimum_value_warning": "100",
+ "maximum_value_warning": "120",
+ "settable_per_mesh": false,
+ "settable_per_extruder": false,
+ "resolve": "sum(extruderValues(\"material_shrinkage_percentage_xy\")) / len(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": 100.0,
+ "enabled": true,
+ "minimum_value": "0.001",
+ "minimum_value_warning": "100",
+ "maximum_value_warning": "120",
+ "settable_per_mesh": false,
+ "settable_per_extruder": false,
+ "resolve": "sum(extruderValues(\"material_shrinkage_percentage_z\")) / len(extruderValues(\"material_shrinkage_percentage_z\"))",
+ "value": "material_shrinkage_percentage"
+ }
+ }
},
"material_crystallinity":
{
diff --git a/resources/setting_visibility/expert.cfg b/resources/setting_visibility/expert.cfg
index 50154a168c..b5b1ab7b1a 100644
--- a/resources/setting_visibility/expert.cfg
+++ b/resources/setting_visibility/expert.cfg
@@ -117,6 +117,7 @@ material_bed_temperature
material_bed_temperature_layer_0
material_adhesion_tendency
material_surface_energy
+material_shrinkage_percentage
material_shrinkage_percentage_xy
material_shrinkage_percentage_z
material_flow