Iohannes
发布于 2025-02-25 / 3 阅读 / 0 评论 / 0 点赞

blender批量更新纹理文件路径

打开脚本窗口

打开 Blender 的脚本编辑器(Window > New Window > Scripting)

运行更新纹理脚本

import bpy
import os

# 设置纹理文件夹路径
texture_folder = "D:/path/to/your/textures"  # 替换为你的纹理文件夹路径

# 获取当前场景中的所有材质
for material in bpy.data.materials:
    if material.use_nodes:
        for node in material.node_tree.nodes:
            if node.type == 'TEX_IMAGE':  # 检查是否为图像纹理节点
                if node.image:
                    # 获取原始纹理文件名
                    original_name = os.path.basename(node.image.filepath)
                    # 构造新的路径
                    new_path = os.path.join(texture_folder, original_name)
                    # 更新纹理路径
                    node.image.filepath = new_path
                    print(f"Updated texture path to: {new_path}")

评论