Skip to content

Instantly share code, notes, and snippets.

@float3
Created February 23, 2023 19:35
Show Gist options
  • Save float3/295f3c2f5152deb51489505ed3377199 to your computer and use it in GitHub Desktop.
Save float3/295f3c2f5152deb51489505ed3377199 to your computer and use it in GitHub Desktop.
import os
import bpy
# Find the Blender output file
outfile = os.getenv("UNITY_BLENDER_EXPORTER_OUTPUT_FILE")
# Do the conversion
print("Starting blender to FBX conversion " + outfile)
import bpy.ops
bpy.ops.export_scene.fbx(filepath=outfile,
check_existing=False,
filter_glob='*.fbx',
use_selection=False,
use_active_collection=False,
global_scale=1.0,
apply_unit_scale=True,
apply_scale_options='FBX_SCALE_ALL',
use_space_transform=True,
bake_space_transform=True,
object_types={'ARMATURE', 'MESH', 'OTHER'},
use_mesh_modifiers=False,
use_mesh_modifiers_render=False,
mesh_smooth_type='OFF',
use_subsurf=False,
use_mesh_edges=False,
use_tspace=False,
use_custom_props=True,
add_leaf_bones=True,
primary_bone_axis='Y',
secondary_bone_axis='X',
use_armature_deform_only=False,
armature_nodetype='NULL',
bake_anim=True,
bake_anim_use_all_bones=True,
bake_anim_use_nla_strips=True,
bake_anim_use_all_actions=True,
bake_anim_force_startend_keying=True,
bake_anim_step=1.0,
bake_anim_simplify_factor=0,
path_mode='AUTO',
embed_textures=True,
batch_mode='OFF',
use_batch_own_dir=True,
use_metadata=True,
axis_forward='-Z',
axis_up='Y')
print("Finished blender to FBX conversion " + outfile)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment