Fix material diameter change

CURA-6868
This commit is contained in:
Lipu Fei 2019-10-15 14:06:30 +02:00
parent d105150f53
commit 59fa73448a
2 changed files with 7 additions and 5 deletions

View File

@ -1322,7 +1322,8 @@ class MachineManager(QObject):
# changed. # changed.
# \param position The extruder stack to update. If provided with None, all # \param position The extruder stack to update. If provided with None, all
# extruder stacks will be updated. # extruder stacks will be updated.
def updateMaterialWithVariant(self, position: Optional[str]) -> None: @pyqtSlot()
def updateMaterialWithVariant(self, position: Optional[str] = None) -> None:
if self._global_container_stack is None: if self._global_container_stack is None:
return return
if position is None: if position is None:
@ -1353,10 +1354,9 @@ class MachineManager(QObject):
self._setMaterial(position_item, new_material) self._setMaterial(position_item, new_material)
else: else:
# The current material is not available, find the preferred one. # The current material is not available, find the preferred one.
if position is not None: approximate_material_diameter = int(self._global_container_stack.extruderList[int(position_item)].getApproximateMaterialDiameter())
approximate_material_diameter = int(self._global_container_stack.extruderList[int(position_item)].getApproximateMaterialDiameter()) material_node = nozzle_node.preferredMaterial(approximate_material_diameter)
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
# instance with the same network key. # instance with the same network key.

View File

@ -111,6 +111,8 @@ TabView
{ {
base.setMetaDataEntry("approximate_diameter", old_approximate_diameter_value, getApproximateDiameter(new_diameter_value).toString()); base.setMetaDataEntry("approximate_diameter", old_approximate_diameter_value, getApproximateDiameter(new_diameter_value).toString());
base.setMetaDataEntry("properties/diameter", properties.diameter, new_diameter_value); base.setMetaDataEntry("properties/diameter", properties.diameter, new_diameter_value);
// CURA-6868 Make sure to update the extruder to user a diameter-compatible material.
Cura.MachineManager.updateMaterialWithVariant()
base.resetSelectedMaterial() base.resetSelectedMaterial()
} }