Blender查找包含丢失图像的材质名
import bpy
import os
for image in bpy.data.images:
try:
old_path = bpy.path.abspath(image.filepath)
if not os.path.isfile(old_path):
print("Image block:", image.name, "is missing.")
for material in bpy.data.materials:
if material.use_nodes:
for node in material.node_tree.nodes:
if node.type == 'TEX_IMAGE' and node.image == image:
print("Image block is used in material of object:", material.name)
except Exception as e:
print('Error when processing image:', image.name)
print('Error details:', str(e))
