mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-11-26 12:21:26 -07:00
Use ContainerTree when updating material upon nozzle switch
Rather than the material manager which is deprecated. Contributes to issue CURA-6600.
This commit is contained in:
parent
37bd7c6b0e
commit
8e06786e7b
1 changed files with 11 additions and 12 deletions
|
|
@ -1317,6 +1317,8 @@ class MachineManager(QObject):
|
||||||
|
|
||||||
## Update the material profile in the current stacks when the variant is
|
## Update the material profile in the current stacks when the variant is
|
||||||
# changed.
|
# changed.
|
||||||
|
# \param position The extruder stack to update. If provided with None, all
|
||||||
|
# extruder stacks will be updated.
|
||||||
def updateMaterialWithVariant(self, position: Optional[str]) -> None:
|
def updateMaterialWithVariant(self, position: Optional[str]) -> None:
|
||||||
if self._global_container_stack is None:
|
if self._global_container_stack is None:
|
||||||
return
|
return
|
||||||
|
|
@ -1333,20 +1335,17 @@ class MachineManager(QObject):
|
||||||
if extruder.variant.getId() != empty_variant_container.getId():
|
if extruder.variant.getId() != empty_variant_container.getId():
|
||||||
current_nozzle_name = extruder.variant.getMetaDataEntry("name")
|
current_nozzle_name = extruder.variant.getMetaDataEntry("name")
|
||||||
|
|
||||||
candidate_materials = ContainerTree.getInstance().machines[self._global_container_stack.definition.getId()].variants[current_nozzle_name].materials
|
# If we can keep the current material after the switch, try to do so.
|
||||||
|
nozzle_node = ContainerTree.getInstance().machines[self._global_container_stack.definition.getId()].variants[current_nozzle_name]
|
||||||
if not candidate_materials:
|
candidate_materials = nozzle_node.materials
|
||||||
self._setMaterial(position_item, container_node = None)
|
if current_material_base_name in candidate_materials: # The current material is also available after the switch. Retain it.
|
||||||
continue
|
|
||||||
|
|
||||||
if current_material_base_name in candidate_materials:
|
|
||||||
new_material = candidate_materials[current_material_base_name]
|
new_material = candidate_materials[current_material_base_name]
|
||||||
self._setMaterial(position_item, new_material)
|
self._setMaterial(position_item, new_material)
|
||||||
continue
|
else:
|
||||||
|
# The current material is not available, find the preferred one.
|
||||||
# The current material is not available, find the preferred one
|
material_diameter = self._global_container_stack.extruders[position].getCompatibleMaterialDiameter()
|
||||||
material_node = MaterialManager.getInstance().getDefaultMaterial(self._global_container_stack, position_item, current_nozzle_name)
|
approximate_material_diameter = round(material_diameter)
|
||||||
if material_node is not None:
|
material_node = nozzle_node.preferredMaterial(approximate_material_diameter)
|
||||||
self._setMaterial(position_item, material_node)
|
self._setMaterial(position_item, material_node)
|
||||||
|
|
||||||
## Given a printer definition name, select the right machine instance. In case it doesn't exist, create a new
|
## Given a printer definition name, select the right machine instance. In case it doesn't exist, create a new
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue