30
$\begingroup$

Is there a quick way to delete all materials in the scene? I have a scene containing 20+ materials and all linked to objects. I'd like to remove all the materials from my blender file.

$\endgroup$

5 Answers 5

50
$\begingroup$

Yes, you can. Easy way would be:

  1. Select all objects, keep one active, remove all materials on it by pressing the "-" button on the right-hand side of material slot list;
  2. Then, from the drop-down list (below it), choose Copy Material to Others. Save the file.

enter image description here

All unused material data will be removed after saving. You cannot see them anymore after reopening.

$\endgroup$
4
  • $\begingroup$ I never knew such a thing ever existed. Found the button, done and gone. $\endgroup$
    – ikel
    Feb 19, 2014 at 4:53
  • 1
    $\begingroup$ This answer just saved me Two thousand, nine hundred and sixty five mouseclicks. You sir, are a legend. $\endgroup$ Nov 20, 2019 at 20:15
  • 1
    $\begingroup$ @JachymMichal Glad to help sir. It's 2.8 now, and we still have to do this kinda quick and dirty trick... T_T $\endgroup$ Nov 21, 2019 at 2:51
  • 1
    $\begingroup$ I have no materials assigned, and reopening the file doesn't remove any of them $\endgroup$
    – stackers
    Jan 3, 2020 at 19:10
25
$\begingroup$

There's an addon Material Utils, which ships with Blender.

Enable it in the User Preferences > Addons, select all objects A, hit Q over 3D View and chose Remove Material Slots:

Material Utils Addon - Remove Material Slots

It currently works on the active object only, despite the tooltip stating it would work for multiple objects. Here's a scripted solution for all selected, editable (non-linked) objects:

import bpy

for ob in bpy.context.selected_editable_objects:
    ob.active_material_index = 0
    for i in range(len(ob.material_slots)):
        bpy.ops.object.material_slot_remove({'object': ob})
$\endgroup$
6
  • 1
    $\begingroup$ According to the tooltip: "Remove all material slots from active objects", so a Copy Material to Others operation is still needed. Btw, you are supposed to suggest a coding way, I bet. :P $\endgroup$ Feb 19, 2014 at 8:05
  • 1
    $\begingroup$ Interesting, it says objects, but seems to work on the active object only. I should either fix the tooltip or add an option to chose what to delete (slots of active object, selected objects, scene objects, all). $\endgroup$
    – CodeManX
    Feb 19, 2014 at 8:13
  • 4
    $\begingroup$ Yeah, This is the CoDEmanX I know of. XD $\endgroup$ Feb 19, 2014 at 8:23
  • 3
    $\begingroup$ Added a scripted solution to really remove all slots of all selected objects :) $\endgroup$
    – CodeManX
    Feb 19, 2014 at 8:27
  • $\begingroup$ I'm working on the Material Utils addon and it looks like it currently fails for a lot of scenarios? I wonder how slot cleanup should behave, I could let it remove all empty slots (but they can actually be assigned without material!), or only slots with materials not used by the object, or a mix of both... Won't work for text objects however, they don't seem to expose the materials :( $\endgroup$
    – CodeManX
    Feb 23, 2014 at 1:39
25
$\begingroup$

to delete all materials:

import bpy
for material in bpy.data.materials:
    material.user_clear()
    bpy.data.materials.remove(material)
$\endgroup$
2
  • 1
    $\begingroup$ You don't need ; in python tho $\endgroup$ Jan 15, 2018 at 13:19
  • $\begingroup$ Would it be an easy update to make your script remove the material slots too? $\endgroup$ Dec 4, 2020 at 5:46
2
$\begingroup$

Here is an updated version of reflog's answer. This removes all materials programatically.

for material in bpy.data.materials:
        bpy.data.materials.remove(material, do_unlink=True)

I was getting errors when using material.user_clear(), and read that it's something that shouldn't be done anymore. The above works flawlessly in the current version of Blender (3.0.0 at the time of writing).

$\endgroup$
0
$\begingroup$

just had to solve this problem too. The other answers here didnt work for me. My solution:

  1. Select all of the objects you want to remove materials from.
  2. In Object Mode, Join them (menu: Object/Join or shortcut: ctrl + 'j').
  3. Remove the material(s) in the materials panel by pressing the '-' button.
  4. In Edit Mode, select all ('a'), press 'p' and separate (by loose parts in my case) to get your individual objects back.
$\endgroup$
3
  • 3
    $\begingroup$ I'd use this if and only if none of the original objects had loose parts, or shared the same origin, or had meaningful names (mesh or object). $\endgroup$
    – batFINGER
    Oct 21, 2017 at 12:04
  • 1
    $\begingroup$ This might not work as expected for mesh objects containing several meshes, like e.g. monkey. After your procedure there will be monkey and 2 eyes objects. Answers shown here still work for this situation $\endgroup$
    – Mr Zak
    Oct 21, 2017 at 12:28
  • $\begingroup$ above critiques accepted :o) $\endgroup$
    – tinyMind
    Oct 21, 2017 at 17:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .