mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-06-04 11:14:21 +08:00
Improve readability
This commit is contained in:
parent
b8ea762242
commit
ddc94e9bec
@ -250,30 +250,33 @@ class MachineSettingsAction(MachineAction):
|
|||||||
return
|
return
|
||||||
|
|
||||||
definition = self._global_container_stack.getBottom()
|
definition = self._global_container_stack.getBottom()
|
||||||
if definition.getProperty("machine_gcode_flavor", "value") == "UltiGCode" and not definition.getMetaDataEntry("has_materials", False):
|
if definition.getProperty("machine_gcode_flavor", "value") != "UltiGCode" or definition.getMetaDataEntry("has_materials", False):
|
||||||
has_materials = self._global_container_stack.getProperty("machine_gcode_flavor", "value") != "UltiGCode"
|
# In other words: only continue for the UM2 (extended), but not for the UM2+
|
||||||
|
return
|
||||||
|
|
||||||
material_container = self._global_container_stack.material
|
has_materials = self._global_container_stack.getProperty("machine_gcode_flavor", "value") != "UltiGCode"
|
||||||
material_index = self._global_container_stack.getContainerIndex(material_container)
|
|
||||||
|
|
||||||
if has_materials:
|
material_container = self._global_container_stack.material
|
||||||
if "has_materials" in self._global_container_stack.getMetaData():
|
material_index = self._global_container_stack.getContainerIndex(material_container)
|
||||||
self._global_container_stack.setMetaDataEntry("has_materials", True)
|
|
||||||
else:
|
|
||||||
self._global_container_stack.addMetaDataEntry("has_materials", True)
|
|
||||||
|
|
||||||
# Set the material container to a sane default
|
if has_materials:
|
||||||
if material_container.getId() == "empty_material":
|
if "has_materials" in self._global_container_stack.getMetaData():
|
||||||
search_criteria = { "type": "material", "definition": "fdmprinter", "id": "*pla*"}
|
self._global_container_stack.setMetaDataEntry("has_materials", True)
|
||||||
containers = self._container_registry.findInstanceContainers(**search_criteria)
|
|
||||||
if containers:
|
|
||||||
self._global_container_stack.replaceContainer(material_index, containers[0])
|
|
||||||
else:
|
else:
|
||||||
# The metadata entry is stored in an ini, and ini files are parsed as strings only.
|
self._global_container_stack.addMetaDataEntry("has_materials", True)
|
||||||
# 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():
|
|
||||||
self._global_container_stack.removeMetaDataEntry("has_materials")
|
|
||||||
|
|
||||||
self._global_container_stack.material = ContainerRegistry.getInstance().getEmptyInstanceContainer()
|
# Set the material container to a sane default
|
||||||
|
if material_container.getId() == "empty_material":
|
||||||
|
search_criteria = { "type": "material", "definition": "fdmprinter", "id": "*pla*"}
|
||||||
|
containers = self._container_registry.findInstanceContainers(**search_criteria)
|
||||||
|
if containers:
|
||||||
|
self._global_container_stack.replaceContainer(material_index, containers[0])
|
||||||
|
else:
|
||||||
|
# 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.
|
||||||
|
if "has_materials" in self._global_container_stack.getMetaData():
|
||||||
|
self._global_container_stack.removeMetaDataEntry("has_materials")
|
||||||
|
|
||||||
Application.getInstance().globalContainerStackChanged.emit()
|
self._global_container_stack.material = ContainerRegistry.getInstance().getEmptyInstanceContainer()
|
||||||
|
|
||||||
|
Application.getInstance().globalContainerStackChanged.emit()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user