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.
This commit is contained in:
Erwan MATHIEU 2025-04-22 11:32:51 +02:00
parent 38e1140454
commit a6e324b748

View file

@ -8,10 +8,12 @@ import json
import re import re
import threading 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 Machines.Models.ExtrudersModel import ExtrudersModel
from Settings.ExtruderStack import ExtruderStack
from UM.PluginRegistry import PluginRegistry from UM.PluginRegistry import PluginRegistry
from UM.Mesh.MeshWriter import MeshWriter from UM.Mesh.MeshWriter import MeshWriter
from UM.Math.Vector import Vector from UM.Math.Vector import Vector
@ -461,7 +463,7 @@ class ThreeMFWriter(MeshWriter):
return ET.Element("Relationships", xmlns=self._namespaces["relationships"]) return ET.Element("Relationships", xmlns=self._namespaces["relationships"])
@staticmethod @staticmethod
def _getMaterialColor(extruder: ExtruderStack) -> str: def _getMaterialColor(extruder: "ExtruderStack") -> str:
position = int(extruder.getMetaDataEntry("position", default="0")) position = int(extruder.getMetaDataEntry("position", default="0"))
try: try:
default_color = ExtrudersModel.defaultColors[position] default_color = ExtrudersModel.defaultColors[position]