From cbbe37ba5aa7dfb57f832412b99a2d241715f2d9 Mon Sep 17 00:00:00 2001 From: Thomas Barlow Date: Thu, 11 Jan 2024 12:23:47 +0100 Subject: [PATCH] Fix #105096: Material Utilities: Clean Material Slots fails to remove unused slots The code was removing material slots while iterating through them which is generally a bad idea, and it stopped working as the addon expected in Blender 3.0+. The slots are now removed by counting how many slots there are and then removing that number of slots. Pull Request: https://projects.blender.org/blender/blender-addons/pulls/105098 --- materials_utils/__init__.py | 2 +- materials_utils/functions.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/materials_utils/__init__.py b/materials_utils/__init__.py index 18c43c17..6e2dd22d 100644 --- a/materials_utils/__init__.py +++ b/materials_utils/__init__.py @@ -20,7 +20,7 @@ bl_info = { "name": "Material Utilities", "author": "MichaleW, ChrisHinde", - "version": (2, 2, 1), + "version": (2, 2, 2), "blender": (3, 0, 0), "location": "View3D > Shift + Q key", "description": "Menu of material tools (assign, select..) in the 3D View", diff --git a/materials_utils/functions.py b/materials_utils/functions.py index 2bc29045..e1626cb0 100644 --- a/materials_utils/functions.py +++ b/materials_utils/functions.py @@ -16,7 +16,7 @@ def mu_assign_material_slots(object, material_list): active_object = bpy.context.active_object bpy.context.view_layer.objects.active = object - for s in object.material_slots: + for _ in range(len(object.material_slots)): bpy.ops.object.material_slot_remove() # re-add them and assign material