From 5179a4b9c59fcd2a97f8158fd2956a615a4f0313 Mon Sep 17 00:00:00 2001 From: Furgo <148809153+furgo16@users.noreply.github.com> Date: Sun, 5 May 2024 17:14:25 +0200 Subject: [PATCH] Look up materials with full path. Revert changes to the Material namespace --- src/Mod/Arch/ArchMaterial.py | 15 ++------------- src/Mod/Material/importFCMat.py | 4 ++-- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/src/Mod/Arch/ArchMaterial.py b/src/Mod/Arch/ArchMaterial.py index 2c18322e85..3bb8ce136f 100644 --- a/src/Mod/Arch/ArchMaterial.py +++ b/src/Mod/Arch/ArchMaterial.py @@ -694,27 +694,16 @@ class _ArchMaterialTaskPanel: resources_mat_path_std = os.path.join(resources_mat_path, "Standard") user_mat_path = os.path.join(FreeCAD.ConfigGet("UserAppData"), "Material") - paths = [resources_mat_path_std] + paths = [resources_mat_path_std] if os.path.exists(user_mat_path): paths.append(user_mat_path) self.cards = {} - library = None for p in paths: for root, _, f_names in os.walk(p): for f in f_names: b,e = os.path.splitext(f) if e.upper() == ".FCMAT": - if p == resources_mat_path_std: - root_removed = root.replace(resources_mat_path, '') - library = "System" - else: - root_removed = root.replace(p, '') - library = "User" - mat_path = os.path.join(root_removed, f) - # Material paths follow the OS' filesystem hierarchy but - # are stored internally separated by '/', regardless of the platform - # E.g. '/Standard/Metal/Steel/CalculiX-Steel.FCMat' - self.cards[b] = (mat_path.replace(os.sep, '/'), library) + self.cards[b] = os.path.join(root, f) if self.cards: for k in sorted(self.cards): self.form.comboBox_MaterialsInDir.addItem(k) diff --git a/src/Mod/Material/importFCMat.py b/src/Mod/Material/importFCMat.py index cdd5ed0ea9..524ce60a15 100644 --- a/src/Mod/Material/importFCMat.py +++ b/src/Mod/Material/importFCMat.py @@ -97,9 +97,9 @@ def decode(name): # as we had and we might will have problems again and again # https://github.com/berndhahnebach/FreeCAD_bhb/commits/materialdev -def read(filename, library): +def read(filename): materialManager = Materials.MaterialManager() - material = materialManager.getMaterialByPath(filename, library) + material = materialManager.getMaterialByPath(filename) return material.Properties # Metainformation