Skip to content

Commit

Permalink
Merge pull request #19688 from Ultimaker/CURA-11634-Show-Any-Color-in…
Browse files Browse the repository at this point in the history
…-color-submenu

CURA-11634 Show any color in color submenu for machines that support it
  • Loading branch information
HellAholic authored Oct 3, 2024
2 parents 8548581 + 1d1ce9e commit 383c102
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions cura/Machines/MachineNode.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def __init__(self, container_id: str) -> None:
self.preferred_variant_name = my_metadata.get("preferred_variant_name", "")
self.preferred_material = my_metadata.get("preferred_material", "")
self.preferred_quality_type = my_metadata.get("preferred_quality_type", "")
self.supports_abstract_color = parseBool(my_metadata.get("supports_abstract_color", "false"))

self._loadAll()

Expand Down
4 changes: 4 additions & 0 deletions cura/Machines/VariantNode.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ def _loadAll(self) -> None:
filtered_materials = [material for material in materials if not self.machine.isExcludedMaterialBaseFile(material["id"])]

for material in filtered_materials:
if material.get("abstract_color", False) and not self.machine.supports_abstract_color:
continue # do not show abstract color profiles if the machine does not support them
base_file = material["base_file"]
if base_file not in self.materials:
self.materials[base_file] = MaterialNode(material["id"], variant = self)
Expand Down Expand Up @@ -126,6 +128,8 @@ def _materialAdded(self, container: ContainerInterface) -> None:
return # We won't add any materials.
material_definition = container.getMetaDataEntry("definition")

if (not self.machine.supports_abstract_color) and container.getMetaDataEntry("abstract_color", False):
return
base_file = container.getMetaDataEntry("base_file")
if self.machine.isExcludedMaterialBaseFile(base_file):
return # Material is forbidden for this printer.
Expand Down
3 changes: 0 additions & 3 deletions plugins/XmlMaterialProfile/XmlMaterialProfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -918,9 +918,6 @@ def deserializeMetadata(cls, serialized: str, container_id: str) -> List[Dict[st
base_metadata["properties"] = property_values
base_metadata["definition"] = "fdmprinter"

# Certain materials are loaded but should not be visible / selectable to the user.
base_metadata["visible"] = not base_metadata.get("abstract_color", False)

compatible_entries = data.iterfind("./um:settings/um:setting[@key='hardware compatible']", cls.__namespaces)
try:
common_compatibility = cls._parseCompatibleValue(next(compatible_entries).text) # type: ignore
Expand Down
3 changes: 2 additions & 1 deletion resources/definitions/fdmprinter.def.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"preferred_quality_type": "normal",
"machine_extruder_trains": { "0": "fdmextruder" },
"supports_usb_connection": true,
"supports_network_connection": false
"supports_network_connection": false,
"supports_abstract_color": false
},
"settings":
{
Expand Down
1 change: 1 addition & 0 deletions resources/definitions/ultimaker_factor4.def.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"preferred_quality_type": "draft",
"preferred_variant_name": "AA 0.4",
"supported_actions": [ "DiscoverUM3Action" ],
"supports_abstract_color": true,
"supports_material_export": true,
"supports_network_connection": true,
"supports_usb_connection": false,
Expand Down
1 change: 1 addition & 0 deletions resources/definitions/ultimaker_s5.def.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"preferred_variant_buildplate_name": "Glass",
"preferred_variant_name": "AA 0.4",
"supported_actions": [ "DiscoverUM3Action" ],
"supports_abstract_color": true,
"supports_material_export": true,
"supports_network_connection": true,
"supports_usb_connection": false,
Expand Down
1 change: 1 addition & 0 deletions resources/definitions/ultimaker_s7.def.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"preferred_variant_name": "AA 0.4",
"quality_definition": "ultimaker_s5",
"supported_actions": [ "DiscoverUM3Action" ],
"supports_abstract_color": true,
"supports_material_export": true,
"supports_network_connection": true,
"supports_usb_connection": false,
Expand Down

0 comments on commit 383c102

Please sign in to comment.