mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-09 07:56:22 -06:00
Filter material lists for compatible printers.
So that only one identical entry shows up per material, per extruder (per printer). CURA-9689
This commit is contained in:
parent
74f864e285
commit
7dd37c6a53
1 changed files with 11 additions and 10 deletions
|
@ -38,6 +38,12 @@ class CompatibleMachineModel(ListModel):
|
||||||
def _update(self) -> None:
|
def _update(self) -> None:
|
||||||
self.clear()
|
self.clear()
|
||||||
|
|
||||||
|
def _makeMaterial(brand, name, color):
|
||||||
|
if name.lower() in ["", "empty"]:
|
||||||
|
return {"brand": "", "name": "(empty)", "hexcolor": "#ffffff"}
|
||||||
|
else:
|
||||||
|
return {"brand": brand, "name": name, "hexcolor": color}
|
||||||
|
|
||||||
from cura.CuraApplication import CuraApplication
|
from cura.CuraApplication import CuraApplication
|
||||||
machine_manager = CuraApplication.getInstance().getMachineManager()
|
machine_manager = CuraApplication.getInstance().getMachineManager()
|
||||||
|
|
||||||
|
@ -48,11 +54,8 @@ class CompatibleMachineModel(ListModel):
|
||||||
|
|
||||||
# initialize & add current active material:
|
# initialize & add current active material:
|
||||||
for extruder in printer.extruders:
|
for extruder in printer.extruders:
|
||||||
materials = [{
|
materials = [_makeMaterial(
|
||||||
"brand": extruder.activeMaterial.brand,
|
extruder.activeMaterial.brand, extruder.activeMaterial.name, extruder.activeMaterial.color)]
|
||||||
"name": extruder.activeMaterial.name,
|
|
||||||
"hexcolor": extruder.activeMaterial.color,
|
|
||||||
}]
|
|
||||||
extruder_configs[extruder.getPosition()] = {
|
extruder_configs[extruder.getPosition()] = {
|
||||||
"position": extruder.getPosition(),
|
"position": extruder.getPosition(),
|
||||||
"core": extruder.hotendID,
|
"core": extruder.hotendID,
|
||||||
|
@ -66,11 +69,9 @@ class CompatibleMachineModel(ListModel):
|
||||||
Logger.log("w", f"No active extruder for position {extruder.position}.")
|
Logger.log("w", f"No active extruder for position {extruder.position}.")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
extruder_configs[extruder.position]["materials"].append({
|
entry = _makeMaterial(extruder.material.brand, extruder.material.name, extruder.material.color)
|
||||||
"brand": extruder.material.brand,
|
if entry not in extruder_configs[extruder.position]["materials"]:
|
||||||
"name": extruder.material.name,
|
extruder_configs[extruder.position]["materials"].append(entry)
|
||||||
"hexcolor": extruder.material.color
|
|
||||||
})
|
|
||||||
|
|
||||||
if any([len(extruder["materials"]) > 0 for extruder in extruder_configs.values()]):
|
if any([len(extruder["materials"]) > 0 for extruder in extruder_configs.values()]):
|
||||||
self.appendItem({
|
self.appendItem({
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue