FIX: Not all selected are processed

This commit is contained in:
formcore 2022-10-26 03:06:21 +01:00
parent 5967a2cb98
commit bd738026fa
2 changed files with 7 additions and 2 deletions

View File

@ -20,7 +20,7 @@
bl_info = {
"name" : "Simple Material Flattener",
"author" : "Irssss sssssson",
"author" : "Iron",
"description" : "",
"blender" : (3, 3, 1),
"version" : (0, 0, 1),

View File

@ -18,6 +18,8 @@ class SMF_OT_flatten_materials(Operator):
# bpy.ops.object.material_slot_select()
# bpy.ops.object.mode_set(mode='EDIT') (mode='OBJECT)
# bpy.types.ShaderNodeTexImage() ???
# bpy.ops is expensive and should be avoided: re-assign verts without ops?
# view a verts mat? or a mats verts?
selected_objects = [i for i in bpy.context.selected_objects]
store_selected_objects = selected_objects.copy()
@ -27,11 +29,13 @@ class SMF_OT_flatten_materials(Operator):
bpy.ops.object.select_all(action='DESELECT')
for o in selected_objects:
bpy.context.view_layer.objects.active = o
imageMaterialNames = {}
print("gettings materials from %s" % o.name)
# select this object
o.select_set(True)
# switch to edit mode
# switch to edit Mode
bpy.ops.object.material_slot_remove_unused()
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.select_all(action='DESELECT')
@ -47,6 +51,7 @@ class SMF_OT_flatten_materials(Operator):
if not last_image: last_image = image
if last_image == image:
print("add to selection")
o.active_material_index = slot.slot_index
bpy.ops.object.material_slot_select()
continue