Skip to content
Snippets Groups Projects
Commit 141b7673 authored by Michel Selten's avatar Michel Selten
Browse files

Python API update. Again by Anders Nilsson.

* Addition to the Object module.
  obj.getActionIpos(). This method will return a dict with all ipo keys.
  Only works when the Object is an armature.
parent 22a62a28
No related branches found
No related tags found
No related merge requests found
......@@ -89,6 +89,7 @@ struct PyMethodDef M_Object_methods[] = {
static PyObject *Object_buildParts (BPy_Object *self);
static PyObject *Object_clearIpo (BPy_Object *self);
static PyObject *Object_clrParent (BPy_Object *self, PyObject *args);
static PyObject *Object_getActionIpos (BPy_Object *self);
static PyObject *Object_getData (BPy_Object *self);
static PyObject *Object_getDeltaLocation (BPy_Object *self);
static PyObject *Object_getDrawMode (BPy_Object *self);
......@@ -136,6 +137,8 @@ static PyMethodDef BPy_Object_methods[] = {
"Clears parent object. Optionally specify:\n\
mode\n\t2: Keep object transform\nfast\n\t>0: Don't update scene \
hierarchy (faster)"},
{"getActionIpos", (PyCFunction)Object_getActionIpos, METH_NOARGS,
"() - Return a dict of (name:ipo)-keys containing each channel in the object's action"},
{"getData", (PyCFunction)Object_getData, METH_NOARGS,
"Returns the datablock object containing the object's data, e.g. Mesh"},
{"getDeltaLocation", (PyCFunction)Object_getDeltaLocation, METH_NOARGS,
......@@ -642,6 +645,58 @@ int EXPP_add_obdata(struct Object *object)
return 0;
}
static PyObject *Object_getActionIpos (BPy_Object *self)
{
Object *obj=self->object;
PyObject *dict=PyDict_New ();
if (obj->type==OB_ARMATURE) {
if (obj->action!=0) {
bAction *action=obj->action;
bActionChannel *bone=(bActionChannel*)(action->chanbase.first);
// Go through the list of bones
while (bone!=0) {
// Does this bone have an ipo?
if (bone->ipo!=0) {
PyObject *ipo_attr=Ipo_CreatePyObject (bone->ipo);
if (ipo_attr) {
// Insert dict entry using the bone name as key
if (PyDict_SetItemString (dict, bone->name, ipo_attr)!=0) {
Py_DECREF ( ipo_attr );
Py_DECREF ( dict );
return EXPP_ReturnPyObjError (PyExc_RuntimeError,
"Object_getActionIpos: couldn't set dict item");
}
Py_DECREF (ipo_attr);
} else {
Py_DECREF ( dict );
return (PythonReturnErrorObject (PyExc_RuntimeError,
"Object_getActionIpos: could not create Ipo object"));
}
}
bone=bone->next;
}
}
}
return dict;
}
static PyObject *Object_getData (BPy_Object *self)
{
PyObject * data_object;
......
......@@ -49,6 +49,7 @@
#include <BLI_arithb.h>
#include <BLI_blenlib.h>
#include <DNA_armature_types.h>
#include <DNA_action_types.h>
#include <DNA_ID.h>
#include <DNA_ika_types.h>
#include <DNA_listBase.h>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment