From d6c018603130ae9c4737a14bd7e364b9e5f2818a Mon Sep 17 00:00:00 2001 From: Colin Basnett Date: Sun, 29 Sep 2024 12:01:57 -0700 Subject: [PATCH] `get_unique_materials` now preserves the order that the materials were encountered --- io_scene_ase/exporter.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/io_scene_ase/exporter.py b/io_scene_ase/exporter.py index 667cc98..048fbb8 100644 --- a/io_scene_ase/exporter.py +++ b/io_scene_ase/exporter.py @@ -52,14 +52,15 @@ class ASE_PG_export(PropertyGroup): def get_unique_materials(mesh_objects: Iterable[Object]) -> List[Material]: - materials = set() + materials = [] for mesh_object in mesh_objects: for i, material_slot in enumerate(mesh_object.material_slots): material = material_slot.material if material is None: raise RuntimeError(f'Material slots cannot be empty ({mesh_object.name}, material slot index {i})') - materials.add(material) - return list(materials) + if material not in materials: + materials.append(material) + return materials def populate_material_list(mesh_objects: Iterable[Object], material_list):