0
$\begingroup$

When packing external data into a blend file, it comes up with errors saying that several images are missing. I have tracked down some of the images to materials which came with purchased models (and then deleted them from the material since the files don't exist, and are not that important) but after going through almost every material in the blend file, I still get an error on packing with some images still not being found. Is there any way to find out where these rogue files are being referenced from. Looking at similar questions I see some people recommend a materials manager add on which seems to put all images into single directory, but I can't see how that would help me find the materials that are referencing non-existing image files. Just so annoying that I can't search for the images within the ouliner, and then see their parent material. Hopefully I'm missing something obvious.

$\endgroup$
3
  • $\begingroup$ Hi :). Simply go File > External Data > Report missing files. You can see all the missing files listed in the console (Window > Toggle System Console) $\endgroup$ May 28, 2021 at 14:11
  • 1
    $\begingroup$ Hi Jachym, Thanks for responding, but it doesn't answer the question. Doing as you suggest tells me the pathname of some non-existant files, and at that point there is nothing more i can do to fix the problem other than create some dummy images at those locations to get rid of the error. My question is how do if find where in the blend file these rogue images are referenced so that I can remove/modify those references. $\endgroup$
    – Brian
    May 28, 2021 at 15:16
  • 2
    $\begingroup$ OK... It seems like it is impossible to find where an image is referenced from. Should be really simple - Blender recognised and reports the error but not where it found it! crazy, $\endgroup$
    – Brian
    Jun 10, 2021 at 13:16

1 Answer 1

0
$\begingroup$

It could be more efficient, but here's a crude script that lists all objects that have materials with image textures, and the image filepath (if it has one) of each image texture.

import bpy

def find_nodes_by_type(material, node_type):
    node_list = []
    if material.use_nodes and material.node_tree:
            for n in material.node_tree.nodes:
                if n.type == node_type:
                    node_list.append(n)
    return node_list

material_set = set()

for object in bpy.context.scene.objects:
    for material in object.material_slots:
        image_nodes = find_nodes_by_type(material.material, "TEX_IMAGE")
        if len(image_nodes):
            material_set.add(material)
        
for object in bpy.context.scene.objects:
    for material in object.material_slots:
        if material in material_set:
            print(f"Object {object.name}, uses material {material.name}")
            image_nodes = find_nodes_by_type(material.material, "TEX_IMAGE")    
            for image_node in image_nodes:
                if image_node.image:
                    print(f"\timage {image_node.image.name} has file '{image_node.image.filepath}'")
                else:
                    print("\tEmpty image texture")
$\endgroup$

You must log in to answer this question.

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