mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-07 06:57:28 -06:00
Fix 1/2 of the duplication material bug.
The material is added multiple times to the variant nodes, and overwriting it with the eventual right one was going wrong. This does not solve it entirely (because the less specific one still ends up selected _initially_ because it gets added first, and the order can't be guaranteed. part of CURA-6863
This commit is contained in:
parent
25db711adc
commit
4277ede64f
2 changed files with 6 additions and 7 deletions
|
@ -1,6 +1,5 @@
|
||||||
# Copyright (c) 2019 Ultimaker B.V.
|
# Copyright (c) 2019 Ultimaker B.V.
|
||||||
# Cura is released under the terms of the LGPLv3 or higher.
|
# Cura is released under the terms of the LGPLv3 or higher.
|
||||||
|
|
||||||
from typing import Optional, TYPE_CHECKING
|
from typing import Optional, TYPE_CHECKING
|
||||||
|
|
||||||
from UM.Logger import Logger
|
from UM.Logger import Logger
|
||||||
|
@ -111,18 +110,18 @@ class VariantNode(ContainerNode):
|
||||||
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 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:
|
if material_definition != "fdmprinter" and material_definition != self.machine.container_id:
|
||||||
return
|
return
|
||||||
material_variant = container.getMetaDataEntry("variant_name", "empty")
|
material_variant = container.getMetaDataEntry("variant_name")
|
||||||
if material_variant != "empty" and material_variant != self.variant_name:
|
if material_variant is not None and material_variant != self.variant_name:
|
||||||
return
|
return
|
||||||
else: # We already have this base profile. Replace the base profile if the new one is more specific.
|
else: # We already have this base profile. Replace the base profile if the new one is more specific.
|
||||||
new_definition = container.getMetaDataEntry("definition")
|
new_definition = container.getMetaDataEntry("definition")
|
||||||
if new_definition == "fdmprinter":
|
if new_definition == "fdmprinter":
|
||||||
return # Just as unspecific or worse.
|
return # Just as unspecific or worse.
|
||||||
if new_definition != self.machine.container_id:
|
material_variant = container.getMetaDataEntry("variant_name")
|
||||||
|
if new_definition != self.machine.container_id or material_variant != self.variant_name:
|
||||||
return # Doesn't match this set-up.
|
return # Doesn't match this set-up.
|
||||||
original_metadata = ContainerRegistry.getInstance().findContainersMetadata(id = self.materials[base_file].container_id)[0]
|
original_metadata = ContainerRegistry.getInstance().findContainersMetadata(id = self.materials[base_file].container_id)[0]
|
||||||
original_variant = original_metadata.get("variant_name", "empty")
|
if "variant_name" in original_metadata or material_variant is not None:
|
||||||
if original_variant != "empty" or container.getMetaDataEntry("variant_name", "empty") == "empty":
|
|
||||||
return # Original was already specific or just as unspecific as the new one.
|
return # Original was already specific or just as unspecific as the new one.
|
||||||
|
|
||||||
if "empty_material" in self.materials:
|
if "empty_material" in self.materials:
|
||||||
|
|
|
@ -114,7 +114,7 @@ Item
|
||||||
if (base.toActivateNewMaterial)
|
if (base.toActivateNewMaterial)
|
||||||
{
|
{
|
||||||
var position = Cura.ExtruderManager.activeExtruderIndex
|
var position = Cura.ExtruderManager.activeExtruderIndex
|
||||||
Cura.MachineManager.setMaterial(position, base.currentItem.container_node)
|
Cura.MachineManager.setMaterialById(position, base.newRootMaterialIdToSwitchTo)
|
||||||
}
|
}
|
||||||
base.newRootMaterialIdToSwitchTo = ""
|
base.newRootMaterialIdToSwitchTo = ""
|
||||||
base.toActivateNewMaterial = false
|
base.toActivateNewMaterial = false
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue