[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [32498] trunk/blender/release/scripts/ modules/animsys_refactor.py: nodes were being ignored by api update script.

Campbell Barton ideasman42 at gmail.com
Fri Oct 15 13:43:34 CEST 2010


Revision: 32498
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=32498
Author:   campbellbarton
Date:     2010-10-15 13:43:34 +0200 (Fri, 15 Oct 2010)

Log Message:
-----------
nodes were being ignored by api update script.

Modified Paths:
--------------
    trunk/blender/release/scripts/modules/animsys_refactor.py

Modified: trunk/blender/release/scripts/modules/animsys_refactor.py
===================================================================
--- trunk/blender/release/scripts/modules/animsys_refactor.py	2010-10-15 11:30:29 UTC (rev 32497)
+++ trunk/blender/release/scripts/modules/animsys_refactor.py	2010-10-15 11:43:34 UTC (rev 32498)
@@ -111,6 +111,7 @@
 
 
 def find_path_new(id_data, data_path, rna_update_dict, rna_update_from_map):
+    # note!, id_data can be ID type or a node tree
     # ignore ID props for now
     if data_path.startswith("["):
         return data_path
@@ -156,36 +157,43 @@
         rna_update_from_map.setdefault(ren_from, []).append(ren_to)
 
     for id_data in id_iter():
-        anim_data = getattr(id_data, "animation_data", None)
-        if anim_data is None:
-            continue
-        
-        for fcurve in anim_data.drivers:
-            for var in fcurve.driver.variables:
-                if var.type == 'SINGLE_PROP':
-                    for tar in var.targets:
-                        id_data_other = tar.id
-                        data_path = tar.data_path
-                        
-                        if id_data_other and data_path:
-                            data_path_new = find_path_new(id_data_other, data_path, rna_update_dict, rna_update_from_map)
-                            # print(data_path_new)
-                            if data_path_new != data_path:
-                                if not IS_TESTING:
-                                    tar.data_path = data_path_new
-                                print("driver (%s): %s -> %s" % (id_data_other.name, data_path, data_path_new))
+
+        # check node-trees too
+        anim_data_ls = [(id_data, getattr(id_data, "animation_data", None))]
+        node_tree = getattr(id_data, "node_tree", None)
+        if node_tree:
+            anim_data_ls.append((node_tree, node_tree.animation_data))
+
+        for anim_data_base, anim_data in anim_data_ls:
+            if anim_data is None:
+                continue
+
+            for fcurve in anim_data.drivers:
+                for var in fcurve.driver.variables:
+                    if var.type == 'SINGLE_PROP':
+                        for tar in var.targets:
+                            id_data_other = tar.id
+                            data_path = tar.data_path
+                            
+                            if id_data_other and data_path:
+                                data_path_new = find_path_new(id_data_other, data_path, rna_update_dict, rna_update_from_map)
+                                # print(data_path_new)
+                                if data_path_new != data_path:
+                                    if not IS_TESTING:
+                                        tar.data_path = data_path_new
+                                    print("driver (%s): %s -> %s" % (id_data_other.name, data_path, data_path_new))
+                    
                 
             
-        
-        for action in anim_data_actions(anim_data):
-            for fcu in action.fcurves:
-                data_path = fcu.data_path
-                data_path_new = find_path_new(id_data, data_path, rna_update_dict, rna_update_from_map)
-                # print(data_path_new)
-                if data_path_new != data_path:
-                    if not IS_TESTING:
-                        fcu.data_path = data_path_new
-                    print("fcurve (%s): %s -> %s" % (id_data.name, data_path, data_path_new))
+            for action in anim_data_actions(anim_data):
+                for fcu in action.fcurves:
+                    data_path = fcu.data_path
+                    data_path_new = find_path_new(anim_data_base, data_path, rna_update_dict, rna_update_from_map)
+                    # print(data_path_new)
+                    if data_path_new != data_path:
+                        if not IS_TESTING:
+                            fcu.data_path = data_path_new
+                        print("fcurve (%s): %s -> %s" % (id_data.name, data_path, data_path_new))
 
 
 if __name__ == "__main__":





More information about the Bf-blender-cvs mailing list