mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-04-22 21:59:37 +08:00
Fix extruder handling in project loading
CURA-4824 When a machine is getting overriden, it should not try to create the ExtruderStack for the single-extrusion machine loaded from the project file, otherwise that ExtruderStack will become an extra one.
This commit is contained in:
parent
afcf35cb0e
commit
322420092d
@ -24,6 +24,7 @@ from cura.Settings.ExtruderStack import ExtruderStack
|
|||||||
from cura.Settings.GlobalStack import GlobalStack
|
from cura.Settings.GlobalStack import GlobalStack
|
||||||
from cura.Settings.CuraContainerStack import _ContainerIndexes
|
from cura.Settings.CuraContainerStack import _ContainerIndexes
|
||||||
from cura.QualityManager import QualityManager
|
from cura.QualityManager import QualityManager
|
||||||
|
from cura.CuraApplication import CuraApplication
|
||||||
|
|
||||||
from configparser import ConfigParser
|
from configparser import ConfigParser
|
||||||
import zipfile
|
import zipfile
|
||||||
@ -750,8 +751,16 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
|||||||
# If not extruder stacks were saved in the project file (pre 3.1) create one manually
|
# If not extruder stacks were saved in the project file (pre 3.1) create one manually
|
||||||
# We re-use the container registry's addExtruderStackForSingleExtrusionMachine method for this
|
# We re-use the container registry's addExtruderStackForSingleExtrusionMachine method for this
|
||||||
if not extruder_stacks:
|
if not extruder_stacks:
|
||||||
|
if self._resolve_strategies["machine"] == "new":
|
||||||
stack = self._container_registry.addExtruderStackForSingleExtrusionMachine(global_stack, "fdmextruder")
|
stack = self._container_registry.addExtruderStackForSingleExtrusionMachine(global_stack, "fdmextruder")
|
||||||
|
else:
|
||||||
|
stack = global_stack.extruders.get("0")
|
||||||
|
if not stack:
|
||||||
|
# this should not happen
|
||||||
|
Logger.log("e", "Cannot find any extruder in an existing global stack [%s].", global_stack.getId())
|
||||||
if stack:
|
if stack:
|
||||||
|
if global_stack.quality.getId() in ("empty", "empty_quality"):
|
||||||
|
stack.quality = empty_quality_container
|
||||||
if self._resolve_strategies["machine"] == "override":
|
if self._resolve_strategies["machine"] == "override":
|
||||||
# in case the extruder is newly created (for a single-extrusion machine), we need to override
|
# in case the extruder is newly created (for a single-extrusion machine), we need to override
|
||||||
# the existing extruder stack.
|
# the existing extruder stack.
|
||||||
@ -991,6 +1000,9 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
|||||||
for stack in extruder_stacks:
|
for stack in extruder_stacks:
|
||||||
stack.setNextStack(global_stack)
|
stack.setNextStack(global_stack)
|
||||||
stack.containersChanged.emit(stack.getTop())
|
stack.containersChanged.emit(stack.getTop())
|
||||||
|
else:
|
||||||
|
if quality_has_been_changed:
|
||||||
|
CuraApplication.getInstance().getMachineManager().activeQualityChanged.emit()
|
||||||
|
|
||||||
# Actually change the active machine.
|
# Actually change the active machine.
|
||||||
Application.getInstance().setGlobalContainerStack(global_stack)
|
Application.getInstance().setGlobalContainerStack(global_stack)
|
||||||
@ -1040,13 +1052,13 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
|||||||
# find the old material ID
|
# find the old material ID
|
||||||
old_material_id_in_stack = stack.material.getId()
|
old_material_id_in_stack = stack.material.getId()
|
||||||
best_matching_old_material_id = None
|
best_matching_old_material_id = None
|
||||||
best_matching_old_meterial_prefix_length = -1
|
best_matching_old_material_prefix_length = -1
|
||||||
for old_parent_material_id in old_new_material_dict:
|
for old_parent_material_id in old_new_material_dict:
|
||||||
if len(old_parent_material_id) < best_matching_old_meterial_prefix_length:
|
if len(old_parent_material_id) < best_matching_old_material_prefix_length:
|
||||||
continue
|
continue
|
||||||
if len(old_parent_material_id) <= len(old_material_id_in_stack):
|
if len(old_parent_material_id) <= len(old_material_id_in_stack):
|
||||||
if old_parent_material_id == old_material_id_in_stack[0:len(old_parent_material_id)]:
|
if old_parent_material_id == old_material_id_in_stack[0:len(old_parent_material_id)]:
|
||||||
best_matching_old_meterial_prefix_length = len(old_parent_material_id)
|
best_matching_old_material_prefix_length = len(old_parent_material_id)
|
||||||
best_matching_old_material_id = old_parent_material_id
|
best_matching_old_material_id = old_parent_material_id
|
||||||
|
|
||||||
if best_matching_old_material_id is None:
|
if best_matching_old_material_id is None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user