# How to find and eliminate materials that aren't disappearing with orphan data purge

The files I work with have gone through a lot of versions and are linked a lot, and aren't that organized. I am trying to set up a new palette of colors and so I stripped off all the materials in a file (this way). When I reloaded the file most of the materials were gone, but there is this list of them that stubbornly remain, including after purging orphan data as explained here.

There are two groups in the scene that may well have been appended or linked from their own files, or the scene may have been created by deleting everything except these pieces, or both. I don't remember. Nothing is linked here anymore, except that Glossy Black material and that I tracked down in another file, where it was also linked from another file, and I don't remember that, and you see where this is going.

How can I find where those materials are coming from and remove them?

Edit: Ok, the materials seem to be coming from a library that has a broken link. I moved it to a new location, and tried updating the external data links with 'find missing files', but that doesn't seem to have worked for this.

Edit 2: I fixed the broken link to Materials-Lalande by replacing that file, which had been moved, in the place where it was looking for it. Now it doesn't list the library in the resources. Also, I can delete the materials now, which would just reappear when I reloaded the file when I tried to do that before. This is resolving the problem. There remains no indication where blender lists the materials as being used. Each one has 2 users, but I can't find what those users are.

• Your materials don't have a zero in front of their name, so that means they are still used somewhere and can't be purged. Now the challenge is finding out where. Check for orphaned object data or objects on other scenes that might still be using them. – Duarte Farrajota Ramos Sep 21 '18 at 16:32
• @DuarteFarrajotaRamos Could they be on empties? That is the only thing i can think of. How do I check what other files are linked to in this file? – kim holder Sep 21 '18 at 16:44
• Empties can't use materials, but they can be on certain modifiers, particle systems, material overrides, they can still be assigned to object data but your materials slots are set to Object and thus not showing – Duarte Farrajota Ramos Sep 21 '18 at 16:52
• Outliner can be set to Blend File to show linked data, but your materials are not linked otherwise they'd have an L in front of the name – Duarte Farrajota Ramos Sep 21 '18 at 16:54
• Have you tried the solution outlined here? – batFINGER Sep 21 '18 at 17:55

On a peer material basis.

1. Try bpy.data.materials['nameofthematerial'].user_clear()
for i in bpy.data.scenes['Scene'].objects.items():

Will give you a list of the objects in the scene that the material is connected to. Do you have only one scene ? If no you can repeat the operation for each scene, if yes you might find an elegant solution by including another for that will loop through the scenes, but hey got to keep some handwork and this might be futile unless you have ~10 or more scenes.
• The issue with step 3 as I see it is: it will only print if the material is in the active (selected) material slot. IMO need to look at all slots. for name, ob in scene.objects.items(): if thematerial in [s.material for s in ob.material_slots]: Also not that bpy.data.materials.remove(thematerial) now unlinks by default. – batFINGER Sep 22 '18 at 7:27