mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-15 02:37:49 -06:00
Fix update material due to compatible material diameter change
CURA-6821
This commit is contained in:
parent
96a9bcccbb
commit
df105bc822
2 changed files with 14 additions and 5 deletions
|
@ -29,6 +29,7 @@ class MaterialNode(ContainerNode):
|
|||
self.base_file = my_metadata["base_file"]
|
||||
self.material_type = my_metadata["material"]
|
||||
self.guid = my_metadata["GUID"]
|
||||
self.diameter = my_metadata["properties"]["diameter"]
|
||||
self._loadAll()
|
||||
container_registry.containerRemoved.connect(self._onRemoved)
|
||||
container_registry.containerMetaDataChanged.connect(self._onMetadataChanged)
|
||||
|
@ -129,6 +130,7 @@ class MaterialNode(ContainerNode):
|
|||
self.material_type = new_metadata["material"]
|
||||
old_guid = self.guid
|
||||
self.guid = new_metadata["GUID"]
|
||||
self.diameter = new_metadata["properties"]["diameter"]
|
||||
if self.base_file != old_base_file or self.material_type != old_material_type or self.guid != old_guid: # List of quality profiles could've changed.
|
||||
self.qualities = {}
|
||||
self._loadAll() # Re-load the quality profiles for this node.
|
||||
|
|
|
@ -1346,14 +1346,21 @@ class MachineManager(QObject):
|
|||
continue
|
||||
|
||||
current_material_base_name = extruder.material.getMetaDataEntry("base_file")
|
||||
current_nozzle_name = None
|
||||
if extruder.variant.getId() != empty_variant_container.getId():
|
||||
current_nozzle_name = extruder.variant.getMetaDataEntry("name")
|
||||
|
||||
# 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]
|
||||
candidate_materials = nozzle_node.materials
|
||||
if current_material_base_name in candidate_materials: # The current material is also available after the switch. Retain it.
|
||||
old_approximate_material_diameter = None # type: Optional[float]
|
||||
if candidate_materials:
|
||||
candidate_material = list(candidate_materials.values())[0]
|
||||
old_approximate_material_diameter = int(round(float(candidate_material.diameter)))
|
||||
new_approximate_material_diameter = int(self._global_container_stack.extruderList[int(position)].getApproximateMaterialDiameter())
|
||||
|
||||
# Only switch to the old candidate material if the approximate material diameter of the extruder stays the
|
||||
# same.
|
||||
if new_approximate_material_diameter == old_approximate_material_diameter and \
|
||||
current_material_base_name in candidate_materials: # The current material is also available after the switch. Retain it.
|
||||
new_material = candidate_materials[current_material_base_name]
|
||||
self._setMaterial(position_item, new_material)
|
||||
else:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue