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:
authorJoseph Gilbert <ascotan@gmail.com>2006-05-22 01:02:29 +0400
committerJoseph Gilbert <ascotan@gmail.com>2006-05-22 01:02:29 +0400
commit023737daa42c9afc438cb2f0640655000aae2f8e (patch)
tree436951726ba45b0fe651c14baee80ef236ab7992 /source/blender/python/api2_2x/NLA.c
parentf13d63ca48391e8ef2b57f4d336883a13f594f28 (diff)
*python additions
- added a method Action.getFrameNumbers() returns the frames at which keyframes were inserted for this action example usage: import Blender myobj = Blender.Object.Get('Armature') myaction = myobj.getAction() frames = myaction.getFrameNumbers() for frame in frames: print 'bones at frame %d' % frame myobj.evaluatePose(frame) pose = myobj.getPose() for bone in pose.bones.values(): print bone.head, bone.tail
Diffstat (limited to 'source/blender/python/api2_2x/NLA.c')
-rw-r--r--source/blender/python/api2_2x/NLA.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/source/blender/python/api2_2x/NLA.c b/source/blender/python/api2_2x/NLA.c
index 36a7ab2a422..3af8d90f7bb 100644
--- a/source/blender/python/api2_2x/NLA.c
+++ b/source/blender/python/api2_2x/NLA.c
@@ -32,6 +32,7 @@
#include "NLA.h" /*This must come first*/
+#include "DNA_curve_types.h"
#include "BKE_action.h"
#include "BKE_global.h"
#include "BKE_main.h"
@@ -78,6 +79,7 @@ struct PyMethodDef M_NLA_methods[] = {
static PyObject *Action_getName( BPy_Action * self );
static PyObject *Action_setName( BPy_Action * self, PyObject * args );
static PyObject *Action_setActive( BPy_Action * self, PyObject * args );
+static PyObject *Action_getFrameNumbers(BPy_Action *self);
static PyObject *Action_getChannelIpo( BPy_Action * self, PyObject * args );
static PyObject *Action_verifyChannel( BPy_Action * self, PyObject * args );
static PyObject *Action_removeChannel( BPy_Action * self, PyObject * args );
@@ -94,6 +96,8 @@ static PyMethodDef BPy_Action_methods[] = {
"(str) - rename Action"},
{"setActive", ( PyCFunction ) Action_setActive, METH_VARARGS,
"(str) -set this action as the active action for an object"},
+ {"getFrameNumbers", (PyCFunction) Action_getFrameNumbers, METH_NOARGS,
+ "() - get the frame numbers at which keys have been inserted"},
{"getChannelIpo", ( PyCFunction ) Action_getChannelIpo, METH_VARARGS,
"(str) -get the Ipo from a named action channel in this action"},
{"verifyChannel", ( PyCFunction ) Action_verifyChannel, METH_VARARGS,
@@ -277,6 +281,36 @@ static PyObject *Action_setName( BPy_Action * self, PyObject * args )
Py_RETURN_NONE;
}
+static PyObject *Action_getFrameNumbers(BPy_Action *self)
+{
+ bActionChannel *achan = NULL;
+ IpoCurve *icu = NULL;
+ BezTriple *bezt = NULL;
+ int verts;
+ PyObject *py_list = NULL;
+
+ py_list = PyList_New(0);
+ for(achan = self->action->chanbase.first; achan; achan = achan->next){
+ for (icu = achan->ipo->curve.first; icu; icu = icu->next){
+ bezt= icu->bezt;
+ if(bezt) {
+ verts = icu->totvert;
+ while(verts--) {
+ PyObject *value;
+ value = PyInt_FromLong((int)bezt->vec[1][0]);
+ if ( PySequence_Contains(py_list, value) == 0){
+ PyList_Append(py_list, value);
+ }
+ Py_DECREF(value);
+ bezt++;
+ }
+ }
+ }
+ }
+ PyList_Sort(py_list);
+ return EXPP_incr_ret(py_list);
+}
+
static PyObject *Action_setActive( BPy_Action * self, PyObject * args )
{
BPy_Object *object;