5
$\begingroup$

There are a few materials in a blend file I have that I don't think are necessary in the file. However, none of these materials show up in orphan data. I know something is using these materials because if I add the material to another object, it will show a 2 in the material slot (for those who don't know, this means that 2 items are using the material. One of these is the object I plugged it into and the other one is what I want to figure out.) I checked all the meshes in the file and couldn't find a single one that was using the materials I think are not needed. None of these materials have any fake users either. How can I find what is using the material so I can be sure that I can delete it?

$\endgroup$
6
  • 3
    $\begingroup$ Hard to say without seeing the file, but a material can be referenced in several places, for instance in the render passes override or in geometry nodes $\endgroup$
    – Gorgious
    Jul 15 at 6:32
  • 1
    $\begingroup$ To be sure it is not assigned to anything: if you're choosing a material slot on an object and use the dropdown menu to assign a material, is the one in question there marked with a 0 in front of the name? If not, then it's assigned to something, whatever that might be (as @Gorgious pointed out, it's not necessarily a mesh object). $\endgroup$ Jul 15 at 9:23
  • $\begingroup$ @GordonBrinkmann There is no 0 in front of the material $\endgroup$ Jul 20 at 23:09
  • $\begingroup$ Then it's most likely assigned to something... $\endgroup$ Jul 20 at 23:47
  • $\begingroup$ @GordonBrinkmann How can I figure out what it is? I checked all the meshes and couldn't find any that were using the material. $\endgroup$ Jul 21 at 1:16
6
+25
$\begingroup$

This appears to be the same question as How to find out what is using an image except that it's for materials rather than images. The first answer there, in the form of a python script, will solve this as well; by replacing the image bits with material bits.

Copy and paste script block into text editor and run it. Output written to system console:

import bpy
from bpy.types import bpy_prop_collection

def search(ID):
    def users(col):
        ret =  tuple(repr(o) for o in col if o.user_of_id(ID))
        return ret if ret else None
    return filter(None, (
        users(getattr(bpy.data, p)) 
        for p in  dir(bpy.data) 
        if isinstance(
                getattr(bpy.data, p, None), 
                bpy_prop_collection
                )                
        )
        )
        
# report all materials and their users in the console
for mat in bpy.data.materials:
    print (20*"-")
    print(repr(mat))
    print("Users:", mat.users)         
    for users in search(mat):
        print(users)

Console output (default scene):

--------------------
bpy.data.materials['Dots Stroke']
Users: 2
("bpy.data.brushes['Airbrush']", "bpy.data.brushes['Pencil Soft']")
--------------------
bpy.data.materials['Material']
Users: 1
("bpy.data.meshes['Cube']",)

Credit goes to @batFINGER, see How to find out what is using an image in a blend file

$\endgroup$
3
  • 1
    $\begingroup$ @brockman deserves half the bounty for updating the python to use mat.* $\endgroup$ Jul 21 at 21:34
  • $\begingroup$ No problem, was dead easy to adapt it. $\endgroup$
    – brockmann
    Jul 21 at 21:35
  • $\begingroup$ lol, thought this was the question I answered. Cheers for the cite. Appreciate the feedback. $\endgroup$
    – batFINGER
    Jul 23 at 14:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.