examples for keyframing nested paths. based on report from user der_On's report [#25746]

This commit is contained in:
Campbell Barton
2011-03-31 12:45:54 +00:00
parent e4c656c7bf
commit 2900557568
3 changed files with 48 additions and 3 deletions

View File

@@ -0,0 +1,31 @@
"""
Keying Nested Properties
++++++++++++++++++++++++
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")

View File

@@ -0,0 +1,14 @@
"""
Basic Keyframing
++++++++++++++++
This is the most simple example of inserting a keyframe from python.
"""
import bpy
obj = bpy.context.object
# set the keyframe at frame 1
obj.location = 3.0, 4.0, 10.0
obj.keyframe_insert(data_path="location", frame=1)