2
$\begingroup$

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.

scene with no materials and orphan data purged, showing a set of materials still present

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.

enter image description here

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.

enter image description here

$\endgroup$
  • 2
    $\begingroup$ 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. $\endgroup$ – Duarte Farrajota Ramos Sep 21 '18 at 16:32
  • $\begingroup$ @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? $\endgroup$ – kim holder Sep 21 '18 at 16:44
  • 1
    $\begingroup$ 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 $\endgroup$ – Duarte Farrajota Ramos Sep 21 '18 at 16:52
  • $\begingroup$ 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 $\endgroup$ – Duarte Farrajota Ramos Sep 21 '18 at 16:54
  • 1
    $\begingroup$ Have you tried the solution outlined here? $\endgroup$ – batFINGER Sep 21 '18 at 17:55
1
$\begingroup$

On a peer material basis.

  1. Try bpy.data.materials['nameofthematerial'].user_clear()
  2. Reload the file.
  3. If still there,

    for i in bpy.data.scenes['Scene'].objects.items():
        for j in i[1].material_slots: 
            if j.name == 'nameofthematerial':
                print(i[1].name)
    

    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.

$\endgroup$
  • 1
    $\begingroup$ Doing step one deletes the material temporarily until i reload the file, then it's back. When i do step 3, nothing is printed out. I have set up the situation again from an older file to test with. So we might keep playing with it. $\endgroup$ – kim holder Sep 21 '18 at 20:56
  • $\begingroup$ 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. $\endgroup$ – batFINGER Sep 22 '18 at 7:27
  • $\begingroup$ That's true, here i edited to code so that it will ouput the name of any object that contains the material name entered, in any of it's slot. $\endgroup$ – Yvain Sep 22 '18 at 8:01

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.