From c4a79435e45610d50dadfacf2ed2c09ce595f70f Mon Sep 17 00:00:00 2001
From: Bastien Montagne <montagne29@wanadoo.fr>
Date: Fri, 10 Jun 2016 15:54:49 +0200
Subject: [PATCH] Fix T48631: FBX setting "bake_anim_use_nla_strips": True,
 fails to export unique animations to each take.

Active action of object's animdata would override actual NLA's strip animation...
---
 io_scene_fbx/export_fbx_bin.py | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/io_scene_fbx/export_fbx_bin.py b/io_scene_fbx/export_fbx_bin.py
index 98cc265d8..831426d6a 100644
--- a/io_scene_fbx/export_fbx_bin.py
+++ b/io_scene_fbx/export_fbx_bin.py
@@ -1992,6 +1992,7 @@ def fbx_animations(scene_data):
     # Per-NLA strip animstacks.
     if scene_data.settings.bake_anim_use_nla_strips:
         strips = []
+        ob_actions = []
         for ob_obj in scene_data.objects:
             # NLA tracks only for objects, not bones!
             if not ob_obj.is_object:
@@ -1999,6 +2000,9 @@ def fbx_animations(scene_data):
             ob = ob_obj.bdata  # Back to real Blender Object.
             if not ob.animation_data:
                 continue
+            # We have to remove active action from objects, it overwrites strips actions otherwise...
+            ob_actions.append((ob, ob.animation_data.action))
+            ob.animation_data.action = None
             for track in ob.animation_data.nla_tracks:
                 if track.mute:
                     continue
@@ -2017,6 +2021,9 @@ def fbx_animations(scene_data):
         for strip in strips:
             strip.mute = False
 
+        for ob, ob_act in ob_actions:
+            ob.animation_data.action = ob_act
+
     # All actions.
     if scene_data.settings.bake_anim_use_all_actions:
         def validate_actions(act, path_resolve):
-- 
GitLab