[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [35920] trunk/blender/doc/python_api: examples for keyframing nested paths.
Campbell Barton
ideasman42 at gmail.com
Thu Mar 31 14:45:55 CEST 2011
Revision: 35920
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=35920
Author: campbellbarton
Date: 2011-03-31 12:45:54 +0000 (Thu, 31 Mar 2011)
Log Message:
-----------
examples for keyframing nested paths. based on report from user der_On's report [#25746]
Modified Paths:
--------------
trunk/blender/doc/python_api/sphinx_doc_gen.py
Added Paths:
-----------
trunk/blender/doc/python_api/examples/bpy.types.bpy_struct.keyframe_insert.1.py
trunk/blender/doc/python_api/examples/bpy.types.bpy_struct.keyframe_insert.py
Added: trunk/blender/doc/python_api/examples/bpy.types.bpy_struct.keyframe_insert.1.py
===================================================================
--- trunk/blender/doc/python_api/examples/bpy.types.bpy_struct.keyframe_insert.1.py (rev 0)
+++ trunk/blender/doc/python_api/examples/bpy.types.bpy_struct.keyframe_insert.1.py 2011-03-31 12:45:54 UTC (rev 35920)
@@ -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")
Added: trunk/blender/doc/python_api/examples/bpy.types.bpy_struct.keyframe_insert.py
===================================================================
--- trunk/blender/doc/python_api/examples/bpy.types.bpy_struct.keyframe_insert.py (rev 0)
+++ trunk/blender/doc/python_api/examples/bpy.types.bpy_struct.keyframe_insert.py 2011-03-31 12:45:54 UTC (rev 35920)
@@ -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)
Modified: trunk/blender/doc/python_api/sphinx_doc_gen.py
===================================================================
--- trunk/blender/doc/python_api/sphinx_doc_gen.py 2011-03-31 11:49:01 UTC (rev 35919)
+++ trunk/blender/doc/python_api/sphinx_doc_gen.py 2011-03-31 12:45:54 UTC (rev 35920)
@@ -27,7 +27,7 @@
-------------------
- Run this script from blenders root path once you have compiled blender
- ./blender.bin -b -P doc/python_api/sphinx_doc_gen.py
+ ./blender.bin --background --python doc/python_api/sphinx_doc_gen.py
This will generate python files in doc/python_api/sphinx-in/,
assuming that ./blender.bin is or links to the blender executable
@@ -74,7 +74,7 @@
"mathutils.geometry",
)
- FILTER_BPY_TYPES = ("PropertyGroup", "Panel", "Menu", "Operator", "RenderEngine") # allow
+ FILTER_BPY_TYPES = ("bpy_struct", "Panel", "Menu", "Operator", "RenderEngine") # allow
FILTER_BPY_OPS = ("import.scene", ) # allow
# for quick rebuilds
@@ -272,7 +272,7 @@
else:
raise TypeError("type was not GetSetDescriptorType, MethodDescriptorType or ClassMethodDescriptorType")
- write_example_ref(ident, fw, module_name + "." + type_name + "." + identifier)
+ write_example_ref(ident + " ", fw, module_name + "." + type_name + "." + identifier)
fw("\n")
More information about the Bf-blender-cvs
mailing list