Skip to content
Snippets Groups Projects
Commit dd6a83d9 authored by Willian Padovani Germano's avatar Willian Padovani Germano
Browse files

Exppython:

- Minor tweaks related to ipos and Added Object_setIpo and Object_clearIpo to Object.c
- Updated docs
parent f3a809b0
No related branches found
No related tags found
No related merge requests found
......@@ -258,6 +258,11 @@ static PyObject *Camera_getIpo(BPy_Camera *self)
return Ipo_CreatePyObject (ipo);
}
static PyObject *Camera_getName(BPy_Camera *self)
{
......@@ -329,6 +334,8 @@ static PyObject *Camera_getDrawSize(BPy_Camera *self)
"couldn't get Camera.drawSize attribute");
}
static PyObject *Camera_setIpo(BPy_Camera *self, PyObject *args)
{
PyObject *pyipo = 0;
......
......@@ -142,7 +142,7 @@ static PyObject *Camera_setDrawSize(BPy_Camera *self, PyObject *args);
static PyMethodDef BPy_Camera_methods[] = {
/* name, method, flags, doc */
{"getIpo", (PyCFunction)Camera_getIpo, METH_NOARGS,
"() - Return Camera Data Ipo's"},
"() - Return Camera Data Ipo"},
{"getName", (PyCFunction)Camera_getName, METH_NOARGS,
"() - Return Camera Data name"},
{"getType", (PyCFunction)Camera_getType, METH_NOARGS,
......
......@@ -85,8 +85,8 @@ struct PyMethodDef M_Object_methods[] = {
/*****************************************************************************/
/* Python BPy_Object methods declarations: */
/*****************************************************************************/
static PyObject *Object_getIpo (BPy_Object *self);
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_getData (BPy_Object *self);
static PyObject *Object_getDeltaLocation (BPy_Object *self);
......@@ -94,6 +94,7 @@ static PyObject *Object_getDrawMode (BPy_Object *self);
static PyObject *Object_getDrawType (BPy_Object *self);
static PyObject *Object_getEuler (BPy_Object *self);
static PyObject *Object_getInverseMatrix (BPy_Object *self);
static PyObject *Object_getIpo (BPy_Object *self);
static PyObject *Object_getLocation (BPy_Object *self, PyObject *args);
static PyObject *Object_getMaterials (BPy_Object *self);
static PyObject *Object_getMatrix (BPy_Object *self);
......@@ -110,6 +111,7 @@ static PyObject *Object_setDeltaLocation (BPy_Object *self, PyObject *args);
static PyObject *Object_setDrawMode (BPy_Object *self, PyObject *args);
static PyObject *Object_setDrawType (BPy_Object *self, PyObject *args);
static PyObject *Object_setEuler (BPy_Object *self, PyObject *args);
static PyObject *Object_setIpo (BPy_Object *self, PyObject *args);
static PyObject *Object_setLocation (BPy_Object *self, PyObject *args);
static PyObject *Object_setMaterials (BPy_Object *self, PyObject *args);
static PyObject *Object_setName (BPy_Object *self, PyObject *args);
......@@ -123,14 +125,13 @@ static PyMethodDef BPy_Object_methods[] = {
{"buildParts", (PyCFunction)Object_buildParts, METH_NOARGS,
"Recalcs particle system (if any) "},
{"getIpo", (PyCFunction)Object_getIpo, METH_NOARGS,
"Recalcs particle system (if any) "},
"Returns the ipo of this object (if any) "},
{"clrParent", (PyCFunction)Object_clrParent, METH_VARARGS,
"Clears parent object. Optionally specify:\n\
mode\n\t2: Keep object transform\nfast\n\t>0: Don't update scene \
hierarchy (faster)"},
{"getData", (PyCFunction)Object_getData, METH_NOARGS,
"Returns the datablock object containing the object's data, \
e.g. Mesh"},
"Returns the datablock object containing the object's data, e.g. Mesh"},
{"getDeltaLocation", (PyCFunction)Object_getDeltaLocation, METH_NOARGS,
"Returns the object's delta location (x, y, z)"},
{"getDrawMode", (PyCFunction)Object_getDrawMode, METH_NOARGS,
......@@ -199,6 +200,10 @@ objects."},
{"shareFrom", (PyCFunction)Object_shareFrom, METH_VARARGS,
"Link data of self with object specified in the argument. This\n\
works only if self and the object specified are of the same type."},
{"setIpo", (PyCFunction)Object_setIpo, METH_VARARGS,
"(Blender Ipo) - Sets the object's ipo"},
{"clearIpo", (PyCFunction)Object_clearIpo, METH_NOARGS,
"() - Unlink ipo from this object"},
{0}
};
......@@ -253,8 +258,7 @@ PyObject *M_Object_New(PyObject *self, PyObject *args)
if (!PyArg_ParseTuple(args, "s|s", &str_type, &name))
{
PythonReturnErrorObject (PyExc_TypeError,
"string expected as argument");
PythonReturnErrorObject (PyExc_TypeError, "string expected as argument");
return (NULL);
}
......@@ -495,27 +499,35 @@ PyObject *Object_Init (void)
/* Python BPy_Object methods: */
/*****************************************************************************/
#include <DNA_ipo_types.h>
static PyObject *Object_getIpo(BPy_Object *self)
{
PyObject *Ipo_CreatePyObject (Ipo *ipo);
struct Ipo*ipo = self->object->ipo;
if (!ipo) return EXPP_ReturnPyObjError(PyExc_RuntimeError,"Object has no Ipo");
return Ipo_CreatePyObject (ipo);
}
static PyObject *Object_buildParts (BPy_Object *self)
{
void build_particle_system(Object *ob);
struct Object *obj = self->object;
build_particle_system(obj);
Py_INCREF (Py_None);
return (Py_None);
}
static PyObject *Object_clearIpo(BPy_Object *self)
{
Object *ob = self->object;
Ipo *ipo = (Ipo *)ob->ipo;
if (ipo) {
ID *id = &ipo->id;
if (id->us > 0) id->us--;
ob->ipo = NULL;
Py_INCREF (Py_True);
return Py_True;
}
Py_INCREF (Py_False); /* no ipo found */
return Py_False;
}
static PyObject *Object_clrParent (BPy_Object *self, PyObject *args)
{
int mode=0;
......@@ -726,6 +738,19 @@ static PyObject *Object_getInverseMatrix (BPy_Object *self)
return ((PyObject *)inverse);
}
static PyObject *Object_getIpo(BPy_Object *self)
{
struct Ipo *ipo = self->object->ipo;
if (!ipo)
{
Py_INCREF (Py_None);
return Py_None;
}
return Ipo_CreatePyObject (ipo);
}
static PyObject *Object_getLocation (BPy_Object *self, PyObject *args)
{
PyObject *attr = Py_BuildValue ("fff",
......@@ -1121,6 +1146,37 @@ static PyObject *Object_setEuler (BPy_Object *self, PyObject *args)
return (Py_None);
}
static PyObject *Object_setIpo(BPy_Object *self, PyObject *args)
{
PyObject *pyipo = 0;
Ipo *ipo = NULL;
Ipo *oldipo;
if (!PyArg_ParseTuple(args, "O!", &Ipo_Type, &pyipo))
return EXPP_ReturnPyObjError (PyExc_TypeError, "expected Ipo as argument");
ipo = Ipo_FromPyObject(pyipo);
if (!ipo) return EXPP_ReturnPyObjError (PyExc_RuntimeError, "null ipo!");
if (ipo->blocktype != ID_OB)
return EXPP_ReturnPyObjError (PyExc_TypeError,
"this ipo is not an object ipo");
oldipo = self->object->ipo;
if (oldipo) {
ID *id = &oldipo->id;
if (id->us > 0) id->us--;
}
((ID *)&ipo->id)->us++;
self->object->ipo = ipo;
Py_INCREF(Py_None);
return Py_None;
}
static PyObject *Object_setLocation (BPy_Object *self, PyObject *args)
{
float loc1;
......
......@@ -55,6 +55,7 @@
#include <DNA_userdef_types.h>
#include <DNA_view3d_types.h>
#include "bpy_types.h"
#include "gen_utils.h"
#include "modules.h"
#include "vector.h"
......
......@@ -152,9 +152,11 @@ class Object:
Recomputes the particle system. This method only applies to an Object of
the type Effect.
"""
def getIpo():
def clearIpo():
"""
returns the Ipo (if any) associated to the Object.
Unlinks the ipo from this object.
@return: True if there was an ipo linked or False otherwise.
"""
def clrParent(mode = 0, fast = 0):
......@@ -223,6 +225,13 @@ class Object:
@return: the inverse of the matrix of the Object
"""
def getIpo():
"""
Returns the Ipo associated to this object or None if there's no linked ipo.
@rtype: Ipo
@return: the wrapped ipo or None.
"""
def getLocation():
"""
Returns the object's location (x, y, z).
......@@ -381,6 +390,13 @@ class Object:
@param z: The rotation angle in radians for the Z direction.
"""
def setIpo(ipo):
"""
Links an ipo to this object.
@type ipo: Blender Ipo
@param ipo: an object type ipo.
"""
def setLocation(x, y, z):
"""
Sets the object's location.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment