获取材料';和纹理';Python中的名称

获取材料';和纹理';Python中的名称,python,blender,Python,Blender,我想用以下脚本打印所有材质及其纹理的名称: for ob in bpy.data.objects: if ob.type == "MESH": for mat_slot in ob.material_slots: if mat_slot.material: if mat_slot.material.node_tree: print("material

我想用以下脚本打印所有材质及其纹理的名称:

for ob in bpy.data.objects:
    if ob.type == "MESH":
        for mat_slot in ob.material_slots:
            if mat_slot.material:
                if mat_slot.material.node_tree:
                   print("material:" + str(mat_slot.material.node_tree.name))
                   for x in mat_slot.material.node_tree.nodes:
                        if x.type=='TEX_IMAGE':
                           print(" texture: "+str(x.name))
         
但输出只是一般名称,如下所示:

material:Shader Nodetree
 texture: Image Texture
material:Shader Nodetree
 texture: Image Texture
material:Shader Nodetree
 texture: Image Texture      
那么,我如何获得纹理的文件名,比如“
pic.png
”?

我想出来了:

for ob in bpy.data.objects:
    if ob.type == "MESH":
        for mat_slot in ob.material_slots:
            if mat_slot.material:
                if mat_slot.material.node_tree:
                   print("material:" + str(mat_slot.material.name))                
                   for x in mat_slot.material.node_tree.nodes:
                        if x.type=='TEX_IMAGE':
                           print(" texture: "+str(x.image.name))
这张照片是:

material:metal
 texture: metal.png
material:coppercoil
 texture: coil.png
material:steel
 texture: steel.png