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?
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