Blender保存時に自動書き出し
Text Editor 開くimport bpy, os
# Unityプロジェクト内の出力先
EXPORT_PATH = r"D:\\hoge\\hoge\\hoge.fbx"
# 使用するプリセット名
FBX_PRESET = "hoge"
def auto_export(scene):
print(f"[AutoExport] {FBX_PRESET} プリセットで書き出し中...")
bpy.ops.export_scene.fbx('EXEC_DEFAULT',
filepath=EXPORT_PATH,
use_selection=False,
apply_unit_scale=True,
apply_scale_options='FBX_SCALE_ALL',
use_active_collection=False,
bake_space_transform=True,
use_custom_props=True
)
print(f"[AutoExport] 書き出し完了: {EXPORT_PATH}")
# 保存時に呼ばれるイベント登録
bpy.app.handlers.save_post.clear()
bpy.app.handlers.save_post.append(auto_export)
print(f"[AutoExport] 自動エクスポートを有効化しました(プリセット: {FBX_PRESET})")