mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 22:47:29 -06:00
Fix updating material container for extruder when changing gcode flavor
Since single extrusion printers have a single extruder stack now, material container needs to be set on the extruder stack instead of the global stack
This commit is contained in:
parent
b425672ad0
commit
e8a7237391
1 changed files with 12 additions and 9 deletions
|
@ -188,29 +188,32 @@ class MachineSettingsAction(MachineAction):
|
||||||
# In other words: only continue for the UM2 (extended), but not for the UM2+
|
# In other words: only continue for the UM2 (extended), but not for the UM2+
|
||||||
return
|
return
|
||||||
|
|
||||||
|
stacks = ExtruderManager.getInstance().getExtruderStacks()
|
||||||
has_materials = self._global_container_stack.getProperty("machine_gcode_flavor", "value") != "UltiGCode"
|
has_materials = self._global_container_stack.getProperty("machine_gcode_flavor", "value") != "UltiGCode"
|
||||||
|
|
||||||
material_container = self._global_container_stack.material
|
|
||||||
|
|
||||||
if has_materials:
|
if has_materials:
|
||||||
if "has_materials" in self._global_container_stack.getMetaData():
|
if "has_materials" in self._global_container_stack.getMetaData():
|
||||||
self._global_container_stack.setMetaDataEntry("has_materials", True)
|
self._global_container_stack.setMetaDataEntry("has_materials", True)
|
||||||
else:
|
else:
|
||||||
self._global_container_stack.addMetaDataEntry("has_materials", True)
|
self._global_container_stack.addMetaDataEntry("has_materials", True)
|
||||||
|
|
||||||
# Set the material container to a sane default
|
# Set the material container for each extruder to a sane default
|
||||||
if material_container == self._empty_container:
|
for stack in stacks:
|
||||||
search_criteria = { "type": "material", "definition": "fdmprinter", "id": self._global_container_stack.getMetaDataEntry("preferred_material")}
|
material_container = stack.material
|
||||||
materials = self._container_registry.findInstanceContainers(**search_criteria)
|
if material_container == self._empty_container:
|
||||||
if materials:
|
machine_approximate_diameter = str(round(self._global_container_stack.getProperty("material_diameter", "value")))
|
||||||
self._global_container_stack.material = materials[0]
|
search_criteria = { "type": "material", "definition": "fdmprinter", "id": self._global_container_stack.getMetaDataEntry("preferred_material"), "approximate_diameter": machine_approximate_diameter}
|
||||||
|
materials = self._container_registry.findInstanceContainers(**search_criteria)
|
||||||
|
if materials:
|
||||||
|
stack.material = materials[0]
|
||||||
else:
|
else:
|
||||||
# The metadata entry is stored in an ini, and ini files are parsed as strings only.
|
# The metadata entry is stored in an ini, and ini files are parsed as strings only.
|
||||||
# Because any non-empty string evaluates to a boolean True, we have to remove the entry to make it False.
|
# Because any non-empty string evaluates to a boolean True, we have to remove the entry to make it False.
|
||||||
if "has_materials" in self._global_container_stack.getMetaData():
|
if "has_materials" in self._global_container_stack.getMetaData():
|
||||||
self._global_container_stack.removeMetaDataEntry("has_materials")
|
self._global_container_stack.removeMetaDataEntry("has_materials")
|
||||||
|
|
||||||
self._global_container_stack.material = ContainerRegistry.getInstance().getEmptyInstanceContainer()
|
for stack in stacks:
|
||||||
|
stack.material = ContainerRegistry.getInstance().getEmptyInstanceContainer()
|
||||||
|
|
||||||
Application.getInstance().globalContainerStackChanged.emit()
|
Application.getInstance().globalContainerStackChanged.emit()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue