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:
Diffstat (limited to 'doc/python_api/examples/bpy.types.bpy_struct.keyframe_insert.1.py')
-rw-r--r--doc/python_api/examples/bpy.types.bpy_struct.keyframe_insert.1.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/doc/python_api/examples/bpy.types.bpy_struct.keyframe_insert.1.py b/doc/python_api/examples/bpy.types.bpy_struct.keyframe_insert.1.py
new file mode 100644
index 00000000000..faf3b121ec6
--- /dev/null
+++ b/doc/python_api/examples/bpy.types.bpy_struct.keyframe_insert.1.py
@@ -0,0 +1,28 @@
+"""
+Note that when keying data paths which contain nested properties this must be
+done from the :class:`ID` subclass, in this case the :class:`Armature` rather
+then the bone.
+"""
+
+import bpy
+from bpy.props import PointerProperty
+
+
+# define a nested property
+class MyPropGroup(bpy.types.PropertyGroup):
+ nested = bpy.props.FloatProperty(name="Nested", default=0.0)
+
+# register it so its available for all bones
+bpy.utils.register_class(MyPropGroup)
+bpy.types.Bone.my_prop = PointerProperty(type=MyPropGroup,
+ name="MyProp")
+
+# get a bone
+obj = bpy.data.objects["Armature"]
+arm = obj.data
+
+# set the keyframe at frame 1
+arm.bones["Bone"].my_prop_group.nested = 10
+arm.keyframe_insert(data_path='bones["Bone"].my_prop.nested',
+ frame=1,
+ group="Nested Group")