FIX: Not all selected are processed
This commit is contained in:
parent
5967a2cb98
commit
bd738026fa
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
bl_info = {
|
bl_info = {
|
||||||
"name" : "Simple Material Flattener",
|
"name" : "Simple Material Flattener",
|
||||||
"author" : "Irssss sssssson",
|
"author" : "Iron",
|
||||||
"description" : "",
|
"description" : "",
|
||||||
"blender" : (3, 3, 1),
|
"blender" : (3, 3, 1),
|
||||||
"version" : (0, 0, 1),
|
"version" : (0, 0, 1),
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,8 @@ class SMF_OT_flatten_materials(Operator):
|
||||||
# bpy.ops.object.material_slot_select()
|
# bpy.ops.object.material_slot_select()
|
||||||
# bpy.ops.object.mode_set(mode='EDIT') (mode='OBJECT)
|
# bpy.ops.object.mode_set(mode='EDIT') (mode='OBJECT)
|
||||||
# bpy.types.ShaderNodeTexImage() ???
|
# 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]
|
selected_objects = [i for i in bpy.context.selected_objects]
|
||||||
store_selected_objects = selected_objects.copy()
|
store_selected_objects = selected_objects.copy()
|
||||||
|
|
@ -27,11 +29,13 @@ class SMF_OT_flatten_materials(Operator):
|
||||||
bpy.ops.object.select_all(action='DESELECT')
|
bpy.ops.object.select_all(action='DESELECT')
|
||||||
|
|
||||||
for o in selected_objects:
|
for o in selected_objects:
|
||||||
|
bpy.context.view_layer.objects.active = o
|
||||||
imageMaterialNames = {}
|
imageMaterialNames = {}
|
||||||
print("gettings materials from %s" % o.name)
|
print("gettings materials from %s" % o.name)
|
||||||
# select this object
|
# select this object
|
||||||
o.select_set(True)
|
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.object.mode_set(mode='EDIT')
|
||||||
bpy.ops.mesh.select_all(action='DESELECT')
|
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 not last_image: last_image = image
|
||||||
|
|
||||||
if last_image == image:
|
if last_image == image:
|
||||||
|
print("add to selection")
|
||||||
o.active_material_index = slot.slot_index
|
o.active_material_index = slot.slot_index
|
||||||
bpy.ops.object.material_slot_select()
|
bpy.ops.object.material_slot_select()
|
||||||
continue
|
continue
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue