Created
October 23, 2017 19:19
-
-
Save cyaoeu/98ec65bdcf27c1f698c88ada18893d4b to your computer and use it in GitHub Desktop.
fbx_export_animation_with_shapekeyanimation.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bpy | |
path = bpy.path.abspath('//') #path of .blend | |
for object in bpy.context.selected_objects: | |
if object.type == "ARMATURE": #select both mesh and rig | |
rig = object | |
if object.type == "MESH": | |
mesh = object | |
riganimname = rig.animation_data.action.name | |
for shapekeyanim in bpy.data.actions: #try to find shape key animation normal rig action name + _shapekey suffix | |
if shapekeyanim.name == riganimname + "_shapekey": | |
mesh.data.shape_keys.animation_data.action = bpy.data.actions[riganimname + "_shapekey"] | |
action = rig.animation_data.action | |
bpy.ops.screen.frame_jump() | |
bpy.data.scenes[0].frame_end = action.frame_range[1] | |
bpy.ops.export_scene.fbx(filepath=str(path + "/animations/" + "AS_" + action.name + '.fbx'), use_selection = True, object_types={'ARMATURE','MESH'}, bake_anim = True, bake_anim_use_nla_strips=False, bake_anim_use_all_actions=False , add_leaf_bones=False, bake_anim_use_all_bones=True, use_armature_deform_only = True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment