mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 22:47:29 -06:00
Don't use material manager to find or remove materials
That remove function in the material manager was very weird... Contributes to issue CURA-6776.
This commit is contained in:
parent
cc9115b3d3
commit
12043df367
2 changed files with 5 additions and 20 deletions
|
@ -255,7 +255,7 @@ class MaterialManager(QObject):
|
||||||
for result in results:
|
for result in results:
|
||||||
container_registry.removeContainer(result.getMetaDataEntry("id", ""))
|
container_registry.removeContainer(result.getMetaDataEntry("id", ""))
|
||||||
|
|
||||||
@pyqtSlot("QVariant", result=bool)
|
@pyqtSlot("QVariant", result = bool)
|
||||||
def canMaterialBeRemoved(self, material_node: "MaterialNode"):
|
def canMaterialBeRemoved(self, material_node: "MaterialNode"):
|
||||||
# Check if the material is active in any extruder train. In that case, the material shouldn't be removed!
|
# Check if the material is active in any extruder train. In that case, the material shouldn't be removed!
|
||||||
# In the future we might enable this again, but right now, it's causing a ton of issues if we do (since it
|
# In the future we might enable this again, but right now, it's causing a ton of issues if we do (since it
|
||||||
|
|
|
@ -575,7 +575,6 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
||||||
@call_on_qt_thread
|
@call_on_qt_thread
|
||||||
def read(self, file_name):
|
def read(self, file_name):
|
||||||
application = CuraApplication.getInstance()
|
application = CuraApplication.getInstance()
|
||||||
material_manager = application.getMaterialManager()
|
|
||||||
|
|
||||||
archive = zipfile.ZipFile(file_name, "r")
|
archive = zipfile.ZipFile(file_name, "r")
|
||||||
|
|
||||||
|
@ -673,7 +672,7 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
||||||
if self._resolve_strategies["material"] == "override":
|
if self._resolve_strategies["material"] == "override":
|
||||||
# Remove the old materials and then deserialize the one from the project
|
# Remove the old materials and then deserialize the one from the project
|
||||||
root_material_id = material_container.getMetaDataEntry("base_file")
|
root_material_id = material_container.getMetaDataEntry("base_file")
|
||||||
material_manager.removeMaterialByRootId(root_material_id)
|
application.getContainerRegistry().removeContainer(root_material_id)
|
||||||
elif self._resolve_strategies["material"] == "new":
|
elif self._resolve_strategies["material"] == "new":
|
||||||
# Note that we *must* deserialize it with a new ID, as multiple containers will be
|
# Note that we *must* deserialize it with a new ID, as multiple containers will be
|
||||||
# auto created & added.
|
# auto created & added.
|
||||||
|
@ -727,8 +726,6 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
||||||
if self._machine_info.quality_changes_info is None:
|
if self._machine_info.quality_changes_info is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
application = CuraApplication.getInstance()
|
|
||||||
|
|
||||||
# If we have custom profiles, load them
|
# If we have custom profiles, load them
|
||||||
quality_changes_name = self._machine_info.quality_changes_info.name
|
quality_changes_name = self._machine_info.quality_changes_info.name
|
||||||
if self._machine_info.quality_changes_info is not None:
|
if self._machine_info.quality_changes_info is not None:
|
||||||
|
@ -957,9 +954,7 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
||||||
extruder_stack.variant = node.container
|
extruder_stack.variant = node.container
|
||||||
|
|
||||||
def _applyMaterials(self, global_stack, extruder_stack_dict):
|
def _applyMaterials(self, global_stack, extruder_stack_dict):
|
||||||
application = CuraApplication.getInstance()
|
machine_node = ContainerTree.getInstance().machines[global_stack]
|
||||||
material_manager = application.getMaterialManager()
|
|
||||||
|
|
||||||
for position, extruder_stack in extruder_stack_dict.items():
|
for position, extruder_stack in extruder_stack_dict.items():
|
||||||
if position not in self._machine_info.extruder_info_dict:
|
if position not in self._machine_info.extruder_info_dict:
|
||||||
continue
|
continue
|
||||||
|
@ -970,18 +965,8 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
||||||
root_material_id = extruder_info.root_material_id
|
root_material_id = extruder_info.root_material_id
|
||||||
root_material_id = self._old_new_materials.get(root_material_id, root_material_id)
|
root_material_id = self._old_new_materials.get(root_material_id, root_material_id)
|
||||||
|
|
||||||
build_plate_id = global_stack.variant.getId()
|
material_node = machine_node.variants[extruder_stack.variant.getName()].materials[root_material_id]
|
||||||
|
extruder_stack.material = material_node.container # type: InstanceContainer
|
||||||
# get material diameter of this extruder
|
|
||||||
machine_material_diameter = extruder_stack.getCompatibleMaterialDiameter()
|
|
||||||
material_node = material_manager.getMaterialNode(global_stack.definition.getId(),
|
|
||||||
extruder_stack.variant.getName(),
|
|
||||||
build_plate_id,
|
|
||||||
machine_material_diameter,
|
|
||||||
root_material_id)
|
|
||||||
|
|
||||||
if material_node is not None and material_node.container is not None:
|
|
||||||
extruder_stack.material = material_node.container # type: InstanceContainer
|
|
||||||
|
|
||||||
def _applyChangesToMachine(self, global_stack, extruder_stack_dict):
|
def _applyChangesToMachine(self, global_stack, extruder_stack_dict):
|
||||||
# Clear all first
|
# Clear all first
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue