Merged changes in the trunk up to revision 35972.
[blender.git] / doc / python_api / examples / bpy.types.bpy_struct.keyframe_insert.1.py
1 """
2 Keying Nested Properties
3 ++++++++++++++++++++++++
4
5 Note that when keying data paths which contain nested properties this must be
6 done from the :class:`ID` subclass, in this case the :class:`Armature` rather
7 then the bone.
8 """
9
10 import bpy
11 from bpy.props import PointerProperty
12
13
14 # define a nested property
15 class MyPropGroup(bpy.types.PropertyGroup):
16     nested = bpy.props.FloatProperty(name="Nested", default=0.0)
17
18 # register it so its available for all bones
19 bpy.utils.register_class(MyPropGroup)
20 bpy.types.Bone.my_prop = PointerProperty(type=MyPropGroup,
21                                          name="MyProp")
22
23 # get a bone
24 obj = bpy.data.objects["Armature"]
25 arm = obj.data
26
27 # set the keyframe at frame 1
28 arm.bones["Bone"].my_prop_group.nested = 10
29 arm.keyframe_insert(data_path='bones["Bone"].my_prop.nested',
30                     frame=1,
31                     group="Nested Group")