*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
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user