mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-12 17:27:51 -06:00
Do not show a material itself in its linked material list
This commit is contained in:
parent
d78e2d56f7
commit
a115956575
2 changed files with 7 additions and 4 deletions
|
@ -348,15 +348,18 @@ class ContainerManager(QObject):
|
||||||
#
|
#
|
||||||
# \param material_id \type{str} the id of the material for which to get the linked materials.
|
# \param material_id \type{str} the id of the material for which to get the linked materials.
|
||||||
# \return \type{list} a list of names of materials with the same GUID
|
# \return \type{list} a list of names of materials with the same GUID
|
||||||
@pyqtSlot("QVariant", result = "QStringList")
|
@pyqtSlot("QVariant", bool, result = "QStringList")
|
||||||
def getLinkedMaterials(self, material_node):
|
def getLinkedMaterials(self, material_node, exclude_self = False):
|
||||||
guid = material_node.metadata["GUID"]
|
guid = material_node.metadata["GUID"]
|
||||||
|
|
||||||
|
self_root_material_id = material_node.metadata["base_file"]
|
||||||
material_group_list = self._material_manager.getMaterialGroupListByGUID(guid)
|
material_group_list = self._material_manager.getMaterialGroupListByGUID(guid)
|
||||||
|
|
||||||
linked_material_names = []
|
linked_material_names = []
|
||||||
if material_group_list:
|
if material_group_list:
|
||||||
for material_group in material_group_list:
|
for material_group in material_group_list:
|
||||||
|
if exclude_self and material_group.name == self_root_material_id:
|
||||||
|
continue
|
||||||
linked_material_names.append(material_group.root_material_node.metadata["name"])
|
linked_material_names.append(material_group.root_material_node.metadata["name"])
|
||||||
return linked_material_names
|
return linked_material_names
|
||||||
|
|
||||||
|
|
|
@ -36,8 +36,8 @@ TabView
|
||||||
if (!base.containerId || !base.editingEnabled) {
|
if (!base.containerId || !base.editingEnabled) {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
var linkedMaterials = Cura.ContainerManager.getLinkedMaterials(base.currentMaterialNode);
|
var linkedMaterials = Cura.ContainerManager.getLinkedMaterials(base.currentMaterialNode, true);
|
||||||
if (linkedMaterials.length <= 1) {
|
if (linkedMaterials.length == 0) {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
return linkedMaterials.join(", ");
|
return linkedMaterials.join(", ");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue