From 156ac69aad5babbe7c610dfed1a8d808b4b58fb7 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 13 Jan 2007 04:53:41 +0000 Subject: [PATCH] driverExpression - strcpy on wrong type (my bad) fixed. added .sel bool for Ipo curves. --- source/blender/python/api2_2x/Ipocurve.c | 34 +++++++++++++++++-- source/blender/python/api2_2x/doc/IpoCurve.py | 2 ++ 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/source/blender/python/api2_2x/Ipocurve.c b/source/blender/python/api2_2x/Ipocurve.c index 47093a4a014..e04a65600c7 100644 --- a/source/blender/python/api2_2x/Ipocurve.c +++ b/source/blender/python/api2_2x/Ipocurve.c @@ -89,6 +89,9 @@ static int IpoCurve_setDriverObject( C_IpoCurve * self, PyObject * args ); static PyObject *IpoCurve_getDriverChannel( C_IpoCurve * self); static int IpoCurve_setDriverChannel( C_IpoCurve * self, PyObject * args ); static PyObject *IpoCurve_getDriverExpression( C_IpoCurve * self); +static PyObject *IpoCurve_getFlag( C_IpoCurve * self, void *type); +static int IpoCurve_setFlag( C_IpoCurve * self, PyObject *value, void *type); + static int IpoCurve_setDriverExpression( C_IpoCurve * self, PyObject * args ); static PyObject *IpoCurve_getCurval( C_IpoCurve * self, PyObject * args ); static int IpoCurve_setCurval( C_IpoCurve * self, PyObject * key, @@ -143,7 +146,7 @@ static PyGetSetDef C_IpoCurve_getseters[] = { NULL}, {"driver", (getter)IpoCurve_getDriver, (setter)IpoCurve_setDriver, - "The status of the driver 1-on, 0-off", + "The status of the driver 1-object, 2-py expression, 0-off", NULL}, {"driverObject", (getter)IpoCurve_getDriverObject, (setter)IpoCurve_setDriverObject, @@ -165,6 +168,12 @@ static PyGetSetDef C_IpoCurve_getseters[] = { (getter)IpoCurve_newgetExtend, (setter)IpoCurve_newsetExtend, "The extend mode of the curve", NULL}, + + {"sel", + (getter)IpoCurve_getFlag, (setter)IpoCurve_setFlag, + "the selection state of the curve", + (void *)IPO_SELECT}, + {NULL,NULL,NULL,NULL,NULL} }; @@ -942,7 +951,7 @@ static int IpoCurve_setDriverExpression( C_IpoCurve * self, PyObject * arg ) return EXPP_ReturnIntError( PyExc_ValueError, "string is too long, use 127 characters or less" ); - strcpy(&ipo->driver->name, exp); + strcpy(ipo->driver->name, exp); return 0; } @@ -1046,6 +1055,27 @@ static int IpoCurve_newsetExtend( C_IpoCurve * self, PyObject * value ) IPO_HORIZ, IPO_CYCLX, 'h' ); } +static PyObject *IpoCurve_getFlag( C_IpoCurve * self, void *type ) +{ + if (self->ipocurve->flag & (int)type) + Py_RETURN_TRUE; + else + Py_RETURN_FALSE; +} + +static int IpoCurve_setFlag( C_IpoCurve * self, PyObject *value, void *type ) +{ + int param = PyObject_IsTrue( value ); + + if (param) + self->ipocurve->flag |= (int)type; + else + self->ipocurve->flag &= ~(int)type; + + return 0; +} + + /* #####DEPRECATED###### */ static PyObject *IpoCurve_addBezier( C_IpoCurve * self, PyObject * args ) diff --git a/source/blender/python/api2_2x/doc/IpoCurve.py b/source/blender/python/api2_2x/doc/IpoCurve.py index d4d1f89c361..873888cffb4 100644 --- a/source/blender/python/api2_2x/doc/IpoCurve.py +++ b/source/blender/python/api2_2x/doc/IpoCurve.py @@ -54,6 +54,8 @@ class IpoCurve: @type driverObject: Blender Object or None @ivar driverExpression: Python expression used to drive the Ipo curve. [0 - 127 chars] @type driverExpression: string + @ivar sel: The selection state of this curve. + @type sel: bool @ivar driverChannel: Object channel used to drive the Ipo curve. Use module constants: IpoCurve.LOC_X, IpoCurve.LOC_Y, IpoCurve.LOC_Z, IpoCurve.ROT_X, IpoCurve.ROT_Y, IpoCurve.ROT_Z, IpoCurve.SIZE_X,