Created
June 13, 2021 21:05
-
-
Save MichaelGatesDev/5c3b509215d0fdafa6c2e067f4774a50 to your computer and use it in GitHub Desktop.
This will take each action that exists on the armature and export it with the armature with the file named as the action name. For use with Blender 2.91.
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 | |
import os | |
filepath = bpy.data.filepath | |
directory = os.path.dirname(filepath) | |
all_action_names = [a.name for a in bpy.data.actions] | |
def remove_all_actions_except(ignored): | |
for a in bpy.data.actions: | |
if a.name == ignored: | |
continue | |
bpy.data.actions.remove(a) | |
for name in all_action_names: | |
remove_all_actions_except(name) | |
print("Exporting rig with single action: " + name) | |
fbx_file_name = os.path.join( directory , name + ".fbx") | |
bpy.ops.export_scene.fbx( | |
filepath = fbx_file_name, | |
check_existing = False, | |
object_types={'ARMATURE'}, | |
axis_forward = "Z", | |
add_leaf_bones = False, | |
bake_anim_use_nla_strips = False, | |
bake_anim_force_startend_keying = False, | |
embed_textures=False, | |
) | |
bpy.ops.wm.revert_mainfile() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I would love if there were a way to avoid calling
revert_mainfile
as it is the chokepoint of this script, especially on larger files.. I tested on ~120MB files and it took about an hour to export ~350 actions this way. Unfortunately calling 'undo' doesn't work.