Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CURA-11501 Fix excluded materials being sometimes visible #19539

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions cura/Machines/MachineNode.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,17 @@ def preferredGlobalQuality(self) -> "QualityNode":

return self.global_qualities.get(self.preferred_quality_type, next(iter(self.global_qualities.values())))

def isExcludedMaterial(self, material: MaterialNode) -> bool:
def isExcludedMaterialBaseFile(self, material_base_file: str) -> bool:
"""Returns whether the material should be excluded from the list of materials."""
for exclude_material in self.exclude_materials:
if exclude_material in material["id"]:
if exclude_material in material_base_file:
return True
return False

def isExcludedMaterial(self, material: MaterialNode) -> bool:
rburema marked this conversation as resolved.
Show resolved Hide resolved
"""Returns whether the material should be excluded from the list of materials."""
return self.isExcludedMaterialBaseFile(material.base_file)

@UM.FlameProfiler.profile
def _loadAll(self) -> None:
"""(Re)loads all variants under this printer."""
Expand Down
4 changes: 2 additions & 2 deletions cura/Machines/VariantNode.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def _loadAll(self) -> None:
materials = list(materials_per_base_file.values())

# Filter materials based on the exclude_materials property.
filtered_materials = [material for material in materials if not self.machine.isExcludedMaterial(material)]
filtered_materials = [material for material in materials if not self.machine.isExcludedMaterialBaseFile(material["id"])]

for material in filtered_materials:
base_file = material["base_file"]
Expand Down Expand Up @@ -127,7 +127,7 @@ def _materialAdded(self, container: ContainerInterface) -> None:
material_definition = container.getMetaDataEntry("definition")

base_file = container.getMetaDataEntry("base_file")
if base_file in self.machine.exclude_materials:
if self.machine.isExcludedMaterialBaseFile(base_file):
return # Material is forbidden for this printer.
if base_file not in self.materials: # Completely new base file. Always better than not having a file as long as it matches our set-up.
if material_definition != "fdmprinter" and material_definition != self.machine.container_id:
Expand Down
Loading