mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-21 21:58:01 -06:00
Merge branch 'master' into CURA-5334_extruder_def_for_all
This commit is contained in:
commit
553e9bcdc2
2 changed files with 16 additions and 82 deletions
|
@ -507,88 +507,7 @@ class ExtruderManager(QObject):
|
||||||
if not global_stack:
|
if not global_stack:
|
||||||
return
|
return
|
||||||
|
|
||||||
if not global_stack.getMetaDataEntry("has_materials", False):
|
Application.getInstance().getMachineManager()._updateMaterialWithVariant(extruder_position)
|
||||||
return
|
|
||||||
|
|
||||||
extruder_stack = global_stack.extruders[str(extruder_position)]
|
|
||||||
|
|
||||||
material_diameter = extruder_stack.material.getProperty("material_diameter", "value")
|
|
||||||
if not material_diameter:
|
|
||||||
# in case of "empty" material
|
|
||||||
material_diameter = 0
|
|
||||||
|
|
||||||
material_approximate_diameter = str(round(material_diameter))
|
|
||||||
material_diameter = extruder_stack.definitionChanges.getProperty("material_diameter", "value")
|
|
||||||
setting_provider = extruder_stack
|
|
||||||
if not material_diameter:
|
|
||||||
if extruder_stack.definition.hasProperty("material_diameter", "value"):
|
|
||||||
material_diameter = extruder_stack.definition.getProperty("material_diameter", "value")
|
|
||||||
else:
|
|
||||||
material_diameter = global_stack.definition.getProperty("material_diameter", "value")
|
|
||||||
setting_provider = global_stack
|
|
||||||
|
|
||||||
if isinstance(material_diameter, SettingFunction):
|
|
||||||
material_diameter = material_diameter(setting_provider)
|
|
||||||
|
|
||||||
machine_approximate_diameter = str(round(material_diameter))
|
|
||||||
|
|
||||||
if material_approximate_diameter != machine_approximate_diameter:
|
|
||||||
Logger.log("i", "The the currently active material(s) do not match the diameter set for the printer. Finding alternatives.")
|
|
||||||
|
|
||||||
if global_stack.getMetaDataEntry("has_machine_materials", False):
|
|
||||||
materials_definition = global_stack.definition.getId()
|
|
||||||
has_material_variants = global_stack.getMetaDataEntry("has_variants", False)
|
|
||||||
else:
|
|
||||||
materials_definition = "fdmprinter"
|
|
||||||
has_material_variants = False
|
|
||||||
|
|
||||||
old_material = extruder_stack.material
|
|
||||||
search_criteria = {
|
|
||||||
"type": "material",
|
|
||||||
"approximate_diameter": machine_approximate_diameter,
|
|
||||||
"material": old_material.getMetaDataEntry("material", "value"),
|
|
||||||
"brand": old_material.getMetaDataEntry("brand", "value"),
|
|
||||||
"supplier": old_material.getMetaDataEntry("supplier", "value"),
|
|
||||||
"color_name": old_material.getMetaDataEntry("color_name", "value"),
|
|
||||||
"definition": materials_definition
|
|
||||||
}
|
|
||||||
if has_material_variants:
|
|
||||||
search_criteria["variant"] = extruder_stack.variant.getId()
|
|
||||||
|
|
||||||
container_registry = Application.getInstance().getContainerRegistry()
|
|
||||||
empty_material = container_registry.findInstanceContainers(id = "empty_material")[0]
|
|
||||||
|
|
||||||
if old_material == empty_material:
|
|
||||||
search_criteria.pop("material", None)
|
|
||||||
search_criteria.pop("supplier", None)
|
|
||||||
search_criteria.pop("brand", None)
|
|
||||||
search_criteria.pop("definition", None)
|
|
||||||
search_criteria["id"] = extruder_stack.getMetaDataEntry("preferred_material")
|
|
||||||
|
|
||||||
materials = container_registry.findInstanceContainers(**search_criteria)
|
|
||||||
if not materials:
|
|
||||||
# Same material with new diameter is not found, search for generic version of the same material type
|
|
||||||
search_criteria.pop("supplier", None)
|
|
||||||
search_criteria.pop("brand", None)
|
|
||||||
search_criteria["color_name"] = "Generic"
|
|
||||||
materials = container_registry.findInstanceContainers(**search_criteria)
|
|
||||||
if not materials:
|
|
||||||
# Generic material with new diameter is not found, search for preferred material
|
|
||||||
search_criteria.pop("color_name", None)
|
|
||||||
search_criteria.pop("material", None)
|
|
||||||
search_criteria["id"] = extruder_stack.getMetaDataEntry("preferred_material")
|
|
||||||
materials = container_registry.findInstanceContainers(**search_criteria)
|
|
||||||
if not materials:
|
|
||||||
# Preferred material with new diameter is not found, search for any material
|
|
||||||
search_criteria.pop("id", None)
|
|
||||||
materials = container_registry.findInstanceContainers(**search_criteria)
|
|
||||||
if not materials:
|
|
||||||
# Just use empty material as a final fallback
|
|
||||||
materials = [empty_material]
|
|
||||||
|
|
||||||
Logger.log("i", "Selecting new material: %s", materials[0].getId())
|
|
||||||
|
|
||||||
extruder_stack.material = materials[0]
|
|
||||||
|
|
||||||
## Get the value for a setting from a specific extruder.
|
## Get the value for a setting from a specific extruder.
|
||||||
#
|
#
|
||||||
|
|
|
@ -13,6 +13,7 @@ from UM.Workspace.WorkspaceReader import WorkspaceReader
|
||||||
from UM.Application import Application
|
from UM.Application import Application
|
||||||
|
|
||||||
from UM.Logger import Logger
|
from UM.Logger import Logger
|
||||||
|
from UM.Message import Message
|
||||||
from UM.i18n import i18nCatalog
|
from UM.i18n import i18nCatalog
|
||||||
from UM.Signal import postponeSignals, CompressTechnique
|
from UM.Signal import postponeSignals, CompressTechnique
|
||||||
from UM.Settings.ContainerFormatError import ContainerFormatError
|
from UM.Settings.ContainerFormatError import ContainerFormatError
|
||||||
|
@ -470,6 +471,20 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
||||||
Logger.log("w", "File %s is not a valid workspace.", file_name)
|
Logger.log("w", "File %s is not a valid workspace.", file_name)
|
||||||
return WorkspaceReader.PreReadResult.failed
|
return WorkspaceReader.PreReadResult.failed
|
||||||
|
|
||||||
|
# Check if the machine definition exists. If not, indicate failure because we do not import definition files.
|
||||||
|
def_results = self._container_registry.findDefinitionContainersMetadata(id = machine_definition_id)
|
||||||
|
if not def_results:
|
||||||
|
message = Message(i18n_catalog.i18nc("@info:status Don't translate the XML tags <filename> or <message>!",
|
||||||
|
"Project file <filename>{0}</filename> contains an unknown machine type"
|
||||||
|
" <message>{1}</message>. Cannot import the machine."
|
||||||
|
" Models will be imported instead.", file_name, machine_definition_id),
|
||||||
|
title = i18n_catalog.i18nc("@info:title", "Open Project File"))
|
||||||
|
message.show()
|
||||||
|
|
||||||
|
Logger.log("i", "Could unknown machine definition %s in project file %s, cannot import it.",
|
||||||
|
self._machine_info.definition_id, file_name)
|
||||||
|
return WorkspaceReader.PreReadResult.failed
|
||||||
|
|
||||||
# In case we use preRead() to check if a file is a valid project file, we don't want to show a dialog.
|
# In case we use preRead() to check if a file is a valid project file, we don't want to show a dialog.
|
||||||
if not show_dialog:
|
if not show_dialog:
|
||||||
return WorkspaceReader.PreReadResult.accepted
|
return WorkspaceReader.PreReadResult.accepted
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue