Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Leung <aligorith@gmail.com>2016-02-20 07:53:32 +0300
committerJoshua Leung <aligorith@gmail.com>2016-02-20 07:55:11 +0300
commit028c67c81eab341c6d98b139c3a81b91ac3e9308 (patch)
tree4d913512d2aa152cc8414b13f0fa0fe59a2b4491 /release
parent6c02c5fb09eae727c4db57c29c705ebe8be92b6b (diff)
Fix T44453: Exporting Keying Sets referencing node tree properties generates invalid Python code/paths
The problem is that node trees (such as the Material, Lamp, and Compositor node trees) are stored as "nested node trees" on the affected datablocks. They are particularly troublesome to deal with, as the are not easily identified, and also cannot be easily mapped back to the ID's which actually own them. As a result, the usual automated methods do not work when dealing with these!
Diffstat (limited to 'release')
-rw-r--r--release/scripts/startup/bl_operators/anim.py36
1 files changed, 33 insertions, 3 deletions
diff --git a/release/scripts/startup/bl_operators/anim.py b/release/scripts/startup/bl_operators/anim.py
index f3575f26890..05817216a54 100644
--- a/release/scripts/startup/bl_operators/anim.py
+++ b/release/scripts/startup/bl_operators/anim.py
@@ -108,10 +108,40 @@ class ANIM_OT_keying_set_export(Operator):
- id.bl_rna.name gives a name suitable for UI,
with a capitalised first letter, but we need
the plural form that's all lower case
+ - special handling is needed for "nested" ID-blocks
+ (e.g. nodetree in Material)
"""
-
- idtype_list = ksp.id.bl_rna.name.lower() + "s"
- id_bpy_path = "bpy.data.%s[\"%s\"]" % (idtype_list, ksp.id.name)
+ if ksp.id.bl_rna.identifier.startswith("ShaderNodeTree"):
+ # Find material or lamp using this node tree...
+ id_bpy_path = "bpy.data.nodes[\"%s\"]"
+ found = False
+
+ for mat in bpy.data.materials:
+ if mat.node_tree == ksp.id:
+ id_bpy_path = "bpy.data.materials[\"%s\"].node_tree" % (mat.name)
+ found = True
+ break;
+
+ if not found:
+ for lamp in bpy.data.lamps:
+ if lamp.node_tree == ksp.id:
+ id_bpy_path = "bpy.data.lamps[\"%s\"].node_tree" % (lamp.name)
+ found = True
+ break;
+
+ if not found:
+ self.report({'WARN'}, "Could not find material or lamp using Shader Node Tree - %s" % (ksp.id))
+ elif ksp.id.bl_rna.identifier.startswith("CompositorNodeTree"):
+ # Find compositor nodetree using this node tree...
+ for scene in bpy.data.scenes:
+ if scene.node_tree == ksp.id:
+ id_bpy_path = "bpy.data.scenes[\"%s\"].node_tree" % (scene.name)
+ break;
+ else:
+ self.report({'WARN'}, "Could not find scene using Compositor Node Tree - %s" % (ksp.id))
+ else:
+ idtype_list = ksp.id.bl_rna.name.lower() + "s"
+ id_bpy_path = "bpy.data.%s[\"%s\"]" % (idtype_list, ksp.id.name)
# shorthand ID for the ID-block (as used in the script)
short_id = "id_%d" % len(id_to_paths_cache)