0

I'm trying to enumerate and export all images used by all materials in a given .blend project and associating them with named slots / channels used by BSDFs.

My problem is determining which images are assigned to which element in the material's node tree. The toolchain expects things to be named a certain way (ie. "diffuse" instead of "Base Color") and I don't want to always have to remember to change the texture's name every time for every texture. Here's what I've got finding images in Python.

real_texture_list = []
test_texture_list = []

for obj in bpy.context.scene.objects: for s in obj.material_slots: if s.material and s.material.use_nodes: for n in s.material.node_tree.nodes: if n.type == 'TEX_IMAGE': if n.image.type == 'UV_TEST': test_texture_list += [n.image] elif n.image.type == 'IMAGE': real_texture_list += [n.image] elif n.type == 'BSDF_PRINCIPLED': print(n.inputs["Base Color"]) # want the "Base Color" image object so I can name it something else on export

0 Answers0