mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-18 20:28:01 -06:00
Update the _available_materials in the actual _update function
It's confusing that this would be updated in the _canUpdate function. Just cleanliness. Contributes to issue CURA-6600.
This commit is contained in:
parent
ea1c99b708
commit
8ef410e826
4 changed files with 13 additions and 12 deletions
|
@ -115,6 +115,16 @@ class BaseMaterialsModel(ListModel):
|
|||
def _update(self):
|
||||
self._favorite_ids = set(Preferences.getInstance().getValue("cura/favorite_materials").split(";"))
|
||||
|
||||
# Update the available materials (ContainerNode) for the current active machine and extruder setup.
|
||||
global_stack = cura.CuraApplication.CuraApplication.getInstance().getGlobalContainerStack()
|
||||
extruder_stack = global_stack.extruders[str(self._extruder_position)]
|
||||
nozzle_name = None
|
||||
if extruder_stack.variant.getId() != "empty_variant":
|
||||
nozzle_name = extruder_stack.variant.getName()
|
||||
materials = ContainerTree.getInstance().machines[global_stack.definition.getId()].variants[nozzle_name].materials
|
||||
compatible_material_diameter = str(round(extruder_stack.getCompatibleMaterialDiameter()))
|
||||
self._available_materials = {key: material for key, material in materials.items() if material.container.getMetaDataEntry("approximate_diameter") == compatible_material_diameter}
|
||||
|
||||
## This method is used by all material models in the beginning of the
|
||||
# _update() method in order to prevent errors. It's the same in all models
|
||||
# so it's placed here for easy access.
|
||||
|
@ -126,16 +136,7 @@ class BaseMaterialsModel(ListModel):
|
|||
extruder_position = str(self._extruder_position)
|
||||
if extruder_position not in global_stack.extruders:
|
||||
return False
|
||||
extruder_stack = global_stack.extruders[extruder_position]
|
||||
|
||||
nozzle_name = None
|
||||
if extruder_stack.variant.getId() != "empty_variant":
|
||||
nozzle_name = extruder_stack.variant.getName()
|
||||
|
||||
# Update the available materials (ContainerNode) for the current active machine and extruder setup.
|
||||
materials = ContainerTree.getInstance().machines[global_stack.definition.getId()].variants[nozzle_name].materials
|
||||
compatible_material_diameter = str(round(extruder_stack.getCompatibleMaterialDiameter()))
|
||||
self._available_materials = {key: material for key, material in materials.items() if material.container.getMetaDataEntry("approximate_diameter") == compatible_material_diameter}
|
||||
return True
|
||||
|
||||
## This is another convenience function which is shared by all material
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue