mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 22:47:29 -06:00
Fix project loading
CURA-4617
This commit is contained in:
parent
13124ae983
commit
49cac860a8
2 changed files with 110 additions and 71 deletions
|
@ -408,15 +408,7 @@ class CuraContainerRegistry(ContainerRegistry):
|
||||||
|
|
||||||
def addExtruderStackForSingleExtrusionMachine(self, machine, extruder_id):
|
def addExtruderStackForSingleExtrusionMachine(self, machine, extruder_id):
|
||||||
new_extruder_id = extruder_id
|
new_extruder_id = extruder_id
|
||||||
extruder_stack = None
|
|
||||||
|
|
||||||
# if extruders are defined in the machine definition use those instead
|
|
||||||
if machine.extruders and "0" in machine.extruders:
|
|
||||||
new_extruder_id = machine.extruders["0"].getId()
|
|
||||||
extruder_stack = machine.extruders["0"]
|
|
||||||
|
|
||||||
# if the extruder stack doesn't exist yet we create and add it
|
|
||||||
if not extruder_stack:
|
|
||||||
extruder_definitions = self.findDefinitionContainers(id = new_extruder_id)
|
extruder_definitions = self.findDefinitionContainers(id = new_extruder_id)
|
||||||
if not extruder_definitions:
|
if not extruder_definitions:
|
||||||
Logger.log("w", "Could not find definition containers for extruder %s", new_extruder_id)
|
Logger.log("w", "Could not find definition containers for extruder %s", new_extruder_id)
|
||||||
|
@ -490,6 +482,8 @@ class CuraContainerRegistry(ContainerRegistry):
|
||||||
if not extruder_quality_changes_container:
|
if not extruder_quality_changes_container:
|
||||||
Logger.log("w", "Could not find quality_changes named [%s] for extruder [%s]",
|
Logger.log("w", "Could not find quality_changes named [%s] for extruder [%s]",
|
||||||
machine.qualityChanges.getName(), extruder_stack.getId())
|
machine.qualityChanges.getName(), extruder_stack.getId())
|
||||||
|
else:
|
||||||
|
extruder_stack.setQualityChangesById("empty_quality_changes")
|
||||||
|
|
||||||
self.addContainer(extruder_stack)
|
self.addContainer(extruder_stack)
|
||||||
|
|
||||||
|
|
|
@ -760,6 +760,14 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
||||||
if not extruder_stacks:
|
if not extruder_stacks:
|
||||||
stack = self._container_registry.addExtruderStackForSingleExtrusionMachine(global_stack, "fdmextruder")
|
stack = self._container_registry.addExtruderStackForSingleExtrusionMachine(global_stack, "fdmextruder")
|
||||||
if stack:
|
if stack:
|
||||||
|
if self._resolve_strategies["machine"] == "override":
|
||||||
|
# in case the extruder is newly created (for a single-extrusion machine), we need to override
|
||||||
|
# the existing extruder stack.
|
||||||
|
existing_extruder_stack = global_stack.extruders[stack.getMetaDataEntry("position")]
|
||||||
|
for idx in range(len(_ContainerIndexes.IndexTypeMap)):
|
||||||
|
existing_extruder_stack.replaceContainer(idx, stack._containers[idx], postpone_emit = True)
|
||||||
|
extruder_stacks.append(existing_extruder_stack)
|
||||||
|
else:
|
||||||
extruder_stacks.append(stack)
|
extruder_stacks.append(stack)
|
||||||
|
|
||||||
except:
|
except:
|
||||||
|
@ -812,6 +820,8 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
||||||
available_quality_types = [q.getMetaDataEntry("quality_type") for q in available_quality]
|
available_quality_types = [q.getMetaDataEntry("quality_type") for q in available_quality]
|
||||||
|
|
||||||
if global_stack.quality.getMetaDataEntry("quality_type") not in available_quality_types:
|
if global_stack.quality.getMetaDataEntry("quality_type") not in available_quality_types:
|
||||||
|
# We are here because the quality_type specified in the project is not supported any more,
|
||||||
|
# so we need to switch it to the "preferred quality" if present, otherwise "normal".
|
||||||
quality_has_been_changed = True
|
quality_has_been_changed = True
|
||||||
|
|
||||||
# find the preferred quality
|
# find the preferred quality
|
||||||
|
@ -845,6 +855,41 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
||||||
else:
|
else:
|
||||||
# we cannot find the preferred quality. THIS SHOULD NOT HAPPEN
|
# we cannot find the preferred quality. THIS SHOULD NOT HAPPEN
|
||||||
Logger.log("e", "Cannot find the preferred quality for machine [%s]", global_stack.getId())
|
Logger.log("e", "Cannot find the preferred quality for machine [%s]", global_stack.getId())
|
||||||
|
else:
|
||||||
|
# The quality_type specified in the project file is usable, but the quality container itself may not
|
||||||
|
# be correct. For example, for UM2, the quality container can be "draft" while it should be "um2_draft"
|
||||||
|
# instead.
|
||||||
|
# In this code branch, we try to fix those incorrect quality containers.
|
||||||
|
search_criteria = {"type": "quality",
|
||||||
|
"quality_type": global_stack.quality.getMetaDataEntry("quality_type")}
|
||||||
|
search_criteria["definition"] = global_stack.definition.getId()
|
||||||
|
if not parseBool(global_stack.getMetaDataEntry("has_machine_quality", "False")):
|
||||||
|
search_criteria["definition"] = "fdmprinter"
|
||||||
|
|
||||||
|
containers = self._container_registry.findInstanceContainers(**search_criteria)
|
||||||
|
containers = [c for c in containers if not c.getMetaDataEntry("material", "")]
|
||||||
|
if not containers:
|
||||||
|
# cannot find machine-specific qualities, so just use fdmprinter to search again
|
||||||
|
search_criteria["definition"] = "fdmprinter"
|
||||||
|
containers = self._container_registry.findInstanceContainers(**search_criteria)
|
||||||
|
containers = [c for c in containers if not c.getMetaDataEntry("material", "")]
|
||||||
|
|
||||||
|
if containers:
|
||||||
|
new_quality_container = containers[0]
|
||||||
|
global_stack.quality = new_quality_container
|
||||||
|
|
||||||
|
for extruder_stack in extruder_stacks:
|
||||||
|
search_criteria = {"type": "quality",
|
||||||
|
"quality_type": global_stack.quality.getMetaDataEntry("quality_type")}
|
||||||
|
search_criteria["definition"] = global_stack.definition.getId()
|
||||||
|
if not parseBool(global_stack.getMetaDataEntry("has_machine_quality", "False")):
|
||||||
|
search_criteria["definition"] = "fdmprinter"
|
||||||
|
|
||||||
|
if global_stack.getMetaDataEntry("has_machine_materials") and extruder_stack.material.getId() not in ("empty", "empty_material"):
|
||||||
|
search_criteria["material"] = extruder_stack.material.getId()
|
||||||
|
containers = self._container_registry.findInstanceContainers(**search_criteria)
|
||||||
|
if containers:
|
||||||
|
extruder_stack.quality = containers[0]
|
||||||
|
|
||||||
# Replacing the old containers if resolve is "new".
|
# Replacing the old containers if resolve is "new".
|
||||||
# When resolve is "new", some containers will get renamed, so all the other containers that reference to those
|
# When resolve is "new", some containers will get renamed, so all the other containers that reference to those
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue