mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-25 15:44:04 -06:00
Fix exclude materials
CURA-10599
This commit is contained in:
parent
2d7f968932
commit
da589e2f00
2 changed files with 10 additions and 2 deletions
|
@ -14,6 +14,7 @@ from cura.Machines.QualityChangesGroup import QualityChangesGroup # To construc
|
||||||
from cura.Machines.QualityGroup import QualityGroup # To construct groups of quality profiles that belong together.
|
from cura.Machines.QualityGroup import QualityGroup # To construct groups of quality profiles that belong together.
|
||||||
from cura.Machines.QualityNode import QualityNode
|
from cura.Machines.QualityNode import QualityNode
|
||||||
from cura.Machines.VariantNode import VariantNode
|
from cura.Machines.VariantNode import VariantNode
|
||||||
|
from cura.Machines.MaterialNode import MaterialNode
|
||||||
import UM.FlameProfiler
|
import UM.FlameProfiler
|
||||||
|
|
||||||
|
|
||||||
|
@ -167,13 +168,20 @@ class MachineNode(ContainerNode):
|
||||||
|
|
||||||
return self.global_qualities.get(self.preferred_quality_type, next(iter(self.global_qualities.values())))
|
return self.global_qualities.get(self.preferred_quality_type, next(iter(self.global_qualities.values())))
|
||||||
|
|
||||||
|
def is_excluded_material(self, material: MaterialNode) -> 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"]:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
@UM.FlameProfiler.profile
|
@UM.FlameProfiler.profile
|
||||||
def _loadAll(self) -> None:
|
def _loadAll(self) -> None:
|
||||||
"""(Re)loads all variants under this printer."""
|
"""(Re)loads all variants under this printer."""
|
||||||
|
|
||||||
container_registry = ContainerRegistry.getInstance()
|
container_registry = ContainerRegistry.getInstance()
|
||||||
if not self.has_variants:
|
if not self.has_variants:
|
||||||
self.variants["empty"] = VariantNode("empty_variant", machine = self)
|
self.variants["empty"] = VariantNode("empty_variant", machine=self)
|
||||||
self.variants["empty"].materialsChanged.connect(self.materialsChanged)
|
self.variants["empty"].materialsChanged.connect(self.materialsChanged)
|
||||||
else:
|
else:
|
||||||
# Find all the variants for this definition ID.
|
# Find all the variants for this definition ID.
|
||||||
|
|
|
@ -60,7 +60,7 @@ class VariantNode(ContainerNode):
|
||||||
materials = list(materials_per_base_file.values())
|
materials = list(materials_per_base_file.values())
|
||||||
|
|
||||||
# Filter materials based on the exclude_materials property.
|
# Filter materials based on the exclude_materials property.
|
||||||
filtered_materials = [material for material in materials if material["id"] not in self.machine.exclude_materials]
|
filtered_materials = [material for material in materials if not self.machine.is_excluded_material(material)]
|
||||||
|
|
||||||
for material in filtered_materials:
|
for material in filtered_materials:
|
||||||
base_file = material["base_file"]
|
base_file = material["base_file"]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue