搜索内容

ESC 键关闭搜索框

Blender批量导出FBX模型脚本

版块:Blender 发表于:2025-07-30

你的模型是什么格式?导入进blender中的还是用bl制作的?告诉你个方法,批量导出fbx格式的:

1.首先需要把项目另存为.blender工程文件。

2.然后在菜单Scripting中,新建一个脚本,把下面的脚本粘贴,然后运行即可。


# exports every single object to single fbx file.
# Copyright https://www.c4d.com
# Compatible with Blender 3.5.1
 
### fbx files in dir of .blender ###
### bake_space_transform=True,Apply Transform, Bake space transform into object data, avoids getting unwanted rotations to objects when target space is not aligned with Blender’s space (WARNING! experimental option, use at own risk, known to be broken with armatures/animations) ###
 
import bpy
import os
 
# export to blend file location
basedir = os.path.dirname(bpy.data.filepath)
 
print("START Output path = "+basedir)
 
if not basedir:
    raise Exception("Blend file is not saved")
 
objects = bpy.context.collection.objects
 
def exportfunc(objName):
    name = bpy.path.clean_name(objName)
    fn = os.path.join(basedir, name)
 
    # Export gltf
#    bpy.ops.export_scene.gltf(filepath=fn + ".gltf", export_format="GLTF_SEPARATE", export_lights=False, use_selection=True)
    # Export fbx
    bpy.ops.export_scene.fbx(filepath=fn + ".fbx", use_selection=True,bake_space_transform=True)
 
    print("written:", fn)
    return
 
#Deselect all objects
for obj in objects:
    obj.select_set(False)
 
print("===Start save files===")
 
for obj in objects:
    if obj.parent == None:
        if obj.type == 'EMPTY' and len(obj.children) > 0:
            obj.select_set(True)
            for subObj in obj.children:
                subObj.select_set(True)
 
            # some exporters only use the active object
            #view_layer.objects.active = obj
            exportfunc(obj.name)
            
            #Deselect all objects
            for obj in objects:
                obj.select_set(False)
        else:
            obj.select_set(True)
            exportfunc(obj.name)
            obj.select_set(False)
    
print("All save completed!")


分享:

版权声明:

本贴内容采集自互联网。
严禁商用、严禁传播、严禁转载、严禁盗卖。

微信扫一扫