Adding script template for adding Builtin Keying Sets
authorJoshua Leung <aligorith@gmail.com>
Tue, 11 Jan 2011 11:25:24 +0000 (11:25 +0000)
committerJoshua Leung <aligorith@gmail.com>
Tue, 11 Jan 2011 11:25:24 +0000 (11:25 +0000)
release/scripts/templates/builtin_keyingset.py [new file with mode: 0644]

diff --git a/release/scripts/templates/builtin_keyingset.py b/release/scripts/templates/builtin_keyingset.py
new file mode 100644 (file)
index 0000000..878e274
--- /dev/null
@@ -0,0 +1,28 @@
+import bpy
+from keyingsets_utils import *
+
+class BUILTIN_KSI_hello(bpy.types.KeyingSetInfo):
+    bl_label = "Hello World KeyingSet"
+
+    # poll - test for whether Keying Set can be used at all
+    def poll(ksi, context):
+        return (context.active_object) or (context.selected_objects)
+        
+    # iterator - go over all relevant data, calling generate()
+    def iterator(ksi, context, ks):
+        for ob in context.selected_objects:
+            ksi.generate(context, ks, ob)
+            
+    # generator - populate Keying Set with property paths to use
+    def generate(ksi, context, ks, data):
+        id_block = data.id_data
+        
+        ks.paths.add(id_block, "location")
+        
+        for i in range(5):
+            ks.paths.add(id_block, "layers", i, group_method='NAMED', group_name="5x Hello Layers")
+            
+        ks.paths.add(id_block, "show_x_ray", group_method='NONE')
+    
+# manually register 
+bpy.types.register(BUILTIN_KSI_hello)