Skip to main content
1 of 2
brockmann
  • 12.8k
  • 4
  • 51
  • 94

You can set the index of the list to 0, iterate through all slots and override the context of material_slot_remove():

for obj in bpy.context.selected_editable_objects:
    obj.active_material_index = 0
    for i in range(len(obj.material_slots)):
        bpy.ops.object.material_slot_remove({'object': obj})
brockmann
  • 12.8k
  • 4
  • 51
  • 94