From d8ceec8fba4e9ad9cc0aa2ca4cdd02e56376a694 Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Wed, 12 Mar 2025 11:28:40 +0100 Subject: [PATCH] BIM: Fixed material dialog's merge duplicates button - fixes #20124 --- src/Mod/BIM/bimcommands/BimMaterial.py | 31 ++++++++++++++------------ 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/src/Mod/BIM/bimcommands/BimMaterial.py b/src/Mod/BIM/bimcommands/BimMaterial.py index 29061417e7..3b39fd69d3 100644 --- a/src/Mod/BIM/bimcommands/BimMaterial.py +++ b/src/Mod/BIM/bimcommands/BimMaterial.py @@ -150,7 +150,10 @@ class BIM_Material: ) buttonMergeDupes.setIcon(QtGui.QIcon(":/icons/view-refresh.svg")) createButtonsLayout.addWidget(buttonMergeDupes, 1, 0) + self.dlg.buttonMergeDupes = buttonMergeDupes buttonMergeDupes.clicked.connect(self.onMergeDupes) + if len(self.dlg.materials) < 2: + buttonMergeDupes.setEnabled(False) # delete unused buttonDeleteUnused = QtGui.QPushButton( @@ -208,20 +211,15 @@ class BIM_Material: first = True for mat in self.dlg.materials: orig = None - for om in mats: - if om.Label == mat.Label: - orig = om - break - else: - if ( - mat.Label[-1].isdigit() - and mat.Label[-2].isdigit() - and mat.Label[-3].isdigit() - ): - for om in self.dlg.materials: - if om.Label == mat.Label[:-3].strip(): - orig = om - break + if ( + mat.Label[-1].isdigit() + and mat.Label[-2].isdigit() + and mat.Label[-3].isdigit() + ): + for om in self.dlg.materials: + if om.Label == mat.Label[:-3].strip(): + orig = om + break if orig: for par in mat.InList: for prop in par.PropertiesList: @@ -522,6 +520,11 @@ class BIM_Material: i.setFlags(i.flags() | QtCore.Qt.ItemIsEditable) if o.Name == name: self.dlg.matList.setCurrentItem(i) + if hasattr(self.dlg, "buttonMergeDupes"): + if len(self.dlg.materials) > 1: + self.dlg.buttonMergeDupes.setEnabled(True) + else: + self.dlg.buttonMergeDupes.setEnabled(False) def createIcon(self, obj): from PySide import QtCore, QtGui