mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-17 03:37:48 -06:00
Ensure that the materials are loaded again
CURA-6600
This commit is contained in:
parent
6a3a23a725
commit
c0f70c447e
2 changed files with 13 additions and 32 deletions
|
@ -190,41 +190,22 @@ class MaterialManager(QObject):
|
||||||
#
|
#
|
||||||
def getMaterialNode(self, machine_definition_id: str, nozzle_name: Optional[str],
|
def getMaterialNode(self, machine_definition_id: str, nozzle_name: Optional[str],
|
||||||
buildplate_name: Optional[str], diameter: float, root_material_id: str) -> Optional["MaterialNode"]:
|
buildplate_name: Optional[str], diameter: float, root_material_id: str) -> Optional["MaterialNode"]:
|
||||||
# round the diameter to get the approximate diameter
|
container_tree = ContainerTree.getInstance()
|
||||||
rounded_diameter = str(round(diameter))
|
machine_node = container_tree.machines.get(machine_definition_id)
|
||||||
if rounded_diameter not in self._diameter_machine_nozzle_buildplate_material_map:
|
if machine_node is None:
|
||||||
Logger.log("i", "Cannot find materials with diameter [%s] (rounded to [%s]) for root material id [%s]",
|
Logger.log("w", "Could not find machine with definition %s in the container tree", machine_definition_id)
|
||||||
diameter, rounded_diameter, root_material_id)
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# If there are nozzle materials, get the nozzle-specific material
|
variant_node = machine_node.variants.get(nozzle_name)
|
||||||
machine_nozzle_buildplate_material_map = self._diameter_machine_nozzle_buildplate_material_map[rounded_diameter] # type: Dict[str, MaterialNode]
|
if variant_node is None:
|
||||||
machine_node = machine_nozzle_buildplate_material_map.get(machine_definition_id)
|
Logger.log("w", "Could not find variant %s for machine with definition %s in the container tree", nozzle_name, machine_definition_id )
|
||||||
nozzle_node = None
|
return None
|
||||||
buildplate_node = None
|
|
||||||
|
|
||||||
# Fallback for "fdmprinter" if the machine-specific materials cannot be found
|
material_node = variant_node.materials.get(root_material_id)
|
||||||
if machine_node is None:
|
|
||||||
machine_node = machine_nozzle_buildplate_material_map.get(self._default_machine_definition_id)
|
|
||||||
if machine_node is not None and nozzle_name is not None:
|
|
||||||
nozzle_node = machine_node.getChildNode(nozzle_name)
|
|
||||||
if nozzle_node is not None and buildplate_name is not None:
|
|
||||||
buildplate_node = nozzle_node.getChildNode(buildplate_name)
|
|
||||||
|
|
||||||
# Fallback mechanism of finding materials:
|
if material_node is None:
|
||||||
# 1. buildplate-specific material
|
Logger.log("w", "Could not find material %s for machine with definition %s and variant %s in the container tree", root_material_id, machine_definition_id, nozzle_name)
|
||||||
# 2. nozzle-specific material
|
return None
|
||||||
# 3. machine-specific material
|
|
||||||
# 4. generic material (for fdmprinter)
|
|
||||||
nodes_to_check = [buildplate_node, nozzle_node, machine_node,
|
|
||||||
machine_nozzle_buildplate_material_map.get(self._default_machine_definition_id)]
|
|
||||||
|
|
||||||
material_node = None
|
|
||||||
for node in nodes_to_check:
|
|
||||||
if node is not None:
|
|
||||||
material_node = node.material_map.get(root_material_id)
|
|
||||||
if material_node:
|
|
||||||
break
|
|
||||||
|
|
||||||
return material_node
|
return material_node
|
||||||
|
|
||||||
|
|
|
@ -1253,7 +1253,7 @@ class MachineManager(QObject):
|
||||||
if self._global_container_stack is None:
|
if self._global_container_stack is None:
|
||||||
return
|
return
|
||||||
if material_node:
|
if material_node:
|
||||||
self._global_container_stack.extruders[position].material = CuraContainerRegistry.getInstance().findContainers(id = material_node.container_id)
|
self._global_container_stack.extruders[position].material = CuraContainerRegistry.getInstance().findContainers(id = material_node.container_id)[0]
|
||||||
root_material_id = material_node.getMetaDataEntry("base_file", None)
|
root_material_id = material_node.getMetaDataEntry("base_file", None)
|
||||||
else:
|
else:
|
||||||
self._global_container_stack.extruders[position].material = empty_material_container
|
self._global_container_stack.extruders[position].material = empty_material_container
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue