在Blender/Python中查找烘焙纹理三维模型

在Blender/Python中查找烘焙纹理三维模型,python,textures,blender,3d-modelling,bpy,Python,Textures,Blender,3d Modelling,Bpy,从3D模型的数据集中,我需要自动识别哪些模型有烘焙纹理,哪些没有。 我正在使用Blender Python来操纵模型,但我愿意接受建议 (模型太多,无法逐个打开)首先,我们需要一种方法来识别对象是否使用烘焙纹理。假设所有烘焙纹理都使用名称中带有“烘焙”的图像,那么让我们查找图像纹理节点 以下内容将查找当前混合文件中使用名称中带有“烘焙”的图像纹理的所有对象 import bpy for obj in bpy.data.objects: # does object have a mate

从3D模型的数据集中,我需要自动识别哪些模型有烘焙纹理,哪些没有。 我正在使用Blender Python来操纵模型,但我愿意接受建议


(模型太多,无法逐个打开)

首先,我们需要一种方法来识别对象是否使用烘焙纹理。假设所有烘焙纹理都使用名称中带有“烘焙”的图像,那么让我们查找图像纹理节点

以下内容将查找当前混合文件中使用名称中带有“烘焙”的图像纹理的所有对象

import bpy

for obj in bpy.data.objects:
    # does object have a material?
    if len(obj.material_slots) < 1: continue
    for slot in obj.material_slots:
        # skip empty slots and mats that don't use nodes
        if not slot.material or not slot.material.use_nodes: continue
        for n in slot.material.node_tree.nodes:
            if n.type == 'TEX_IMAGE' and 'baked' in n.image.name:
                print(f'{obj.name} uses baked image {n.image.name}')
from glob import glob
from subprocess import call

for blendFile in glob('*.blend'):
    arglist = [
    'blender',
    '--factory-startup',
    '-b',
    blendFile,
    '--python',
    'check_baked.py',
    ]
    print(f'Checking {blendFile}...')
    call(arglist)