From a6e324b748490c80a79f21939d830d42c5a5d43e Mon Sep 17 00:00:00 2001 From: Erwan MATHIEU Date: Tue, 22 Apr 2025 11:32:51 +0200 Subject: [PATCH] Fix extruder stack corruption CURA-12346 For some dark reason, importing the ExtruderStack class in the ThreeMFWriter somehow corrupts the loading of the extruders stacks. As it is imported only for typing, do the import only for type-checking. --- plugins/3MFWriter/ThreeMFWriter.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/plugins/3MFWriter/ThreeMFWriter.py b/plugins/3MFWriter/ThreeMFWriter.py index be0fa1a01b..20c7e5d05c 100644 --- a/plugins/3MFWriter/ThreeMFWriter.py +++ b/plugins/3MFWriter/ThreeMFWriter.py @@ -8,10 +8,12 @@ import json import re import threading -from typing import Optional, cast, List, Dict, Pattern, Set +from typing import Optional, cast, List, Dict, Set, TYPE_CHECKING + +if TYPE_CHECKING: + from Settings.ExtruderStack import ExtruderStack from Machines.Models.ExtrudersModel import ExtrudersModel -from Settings.ExtruderStack import ExtruderStack from UM.PluginRegistry import PluginRegistry from UM.Mesh.MeshWriter import MeshWriter from UM.Math.Vector import Vector @@ -461,7 +463,7 @@ class ThreeMFWriter(MeshWriter): return ET.Element("Relationships", xmlns=self._namespaces["relationships"]) @staticmethod - def _getMaterialColor(extruder: ExtruderStack) -> str: + def _getMaterialColor(extruder: "ExtruderStack") -> str: position = int(extruder.getMetaDataEntry("position", default="0")) try: default_color = ExtrudersModel.defaultColors[position]