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:
authorStephen Swaney <sswaney@centurytel.net>2005-04-17 17:48:16 +0400
committerStephen Swaney <sswaney@centurytel.net>2005-04-17 17:48:16 +0400
commit127abda43db712fecd6c23c9b79a0954782b7b82 (patch)
tree96ec24316d0825fdba1fa9ef75a5d52d8fde6ca6 /source/blender/python
parentfa5d910f93c0cb279f5a41af9cc3d36d53f8c94f (diff)
New methods for Curve module: getBevOb() and setBevOb()
Adds ability to set, clear and get bevel object for a Curve. Contributed by Gergely Erdelyi (dyce). Thanks!
Diffstat (limited to 'source/blender/python')
-rw-r--r--source/blender/python/api2_2x/Curve.c55
-rw-r--r--source/blender/python/api2_2x/doc/Curve.py18
2 files changed, 73 insertions, 0 deletions
diff --git a/source/blender/python/api2_2x/Curve.c b/source/blender/python/api2_2x/Curve.c
index 960042ccea1..e4d91aca25e 100644
--- a/source/blender/python/api2_2x/Curve.c
+++ b/source/blender/python/api2_2x/Curve.c
@@ -46,6 +46,7 @@
#include "CurNurb.h"
#include "Material.h"
+#include "Object.h"
#include "gen_utils.h"
@@ -115,6 +116,9 @@ static PyObject *Curve_appendNurb( BPy_Curve * self, PyObject * args );
static PyObject *Curve_getMaterials( BPy_Curve * self );
+static PyObject *Curve_getBevOb( BPy_Curve * self );
+static PyObject *Curve_setBevOb( BPy_Curve * self, PyObject * args );
+
static PyObject *Curve_getIter( BPy_Curve * self );
static PyObject *Curve_iterNext( BPy_Curve * self );
static PyObject *Curve_update( BPy_Curve * self );
@@ -218,6 +222,10 @@ Sets a control point "},
"( ) - updates display lists after changes to Curve"},
{"getMaterials", ( PyCFunction ) Curve_getMaterials, METH_NOARGS,
"() - returns list of materials assigned to this Curve"},
+ {"getBevOb", ( PyCFunction ) Curve_getBevOb, METH_NOARGS,
+ "() - returns Bevel Object assigned to this Curve"},
+ {"setBevOb", ( PyCFunction ) Curve_setBevOb, METH_VARARGS,
+ "() - assign a Bevel Object to this Curve"},
{NULL, NULL, 0, NULL}
};
@@ -1253,7 +1261,50 @@ static PyObject *Curve_getMaterials( BPy_Curve * self )
}
+/*****************************************************************************/
+/* Function: Curve_getBevOb */
+/* Description: Get the bevel object assign to the curve. */
+/*****************************************************************************/
+static PyObject *Curve_getBevOb( BPy_Curve * self)
+{
+ if( self->curve->bevobj ) {
+ return Object_CreatePyObject( self->curve->bevobj );
+ }
+ return EXPP_incr_ret( Py_None );
+}
+
+/*****************************************************************************/
+/* Function: Curve_setBevOb */
+/* Description: Assign a bevel object to the curve. */
+/*****************************************************************************/
+PyObject *Curve_setBevOb( BPy_Curve * self, PyObject * args )
+{
+ BPy_Object *pybevobj;
+
+ /* Parse and check input args */
+ if( !PyArg_ParseTuple( args, "O", &pybevobj) ) {
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected object or None argument" ) );
+ }
+
+ /* Accept None */
+ if( (PyObject *)pybevobj == Py_None ) {
+ self->curve->bevobj = (Object *)NULL;
+ } else {
+ /* Accept Object with type 'Curve' */
+ if( Object_CheckPyObject( ( PyObject * ) pybevobj ) &&
+ pybevobj->object->type == OB_CURVE) {
+ self->curve->bevobj =
+ Object_FromPyObject( ( PyObject * ) pybevobj );
+ } else {
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected Curve object type or None argument" ) );
+ }
+ }
+
+ return EXPP_incr_ret( Py_None );
+}
/*
* Curve_getIter
@@ -1404,6 +1455,8 @@ static PyObject *CurveGetAttr( BPy_Curve * self, char *name )
return Curve_getRot( self );
if( strcmp( name, "size" ) == 0 )
return Curve_getSize( self );
+ if( strcmp( name, "bevob" ) == 0 )
+ return Curve_getBevOb( self );
#if 0
if( strcmp( name, "numpts" ) == 0 )
return Curve_getNumPoints( self );
@@ -1456,6 +1509,8 @@ static int CurveSetAttr( BPy_Curve * self, char *name, PyObject * value )
error = Curve_setRot( self, valtuple );
else if( strcmp( name, "size" ) == 0 )
error = Curve_setSize( self, valtuple );
+ else if( strcmp( name, "bevob" ) == 0 )
+ error = Curve_setBevOb( self, valtuple );
else { /* Error */
Py_DECREF( valtuple );
diff --git a/source/blender/python/api2_2x/doc/Curve.py b/source/blender/python/api2_2x/doc/Curve.py
index 63df00a2256..5468966b1ba 100644
--- a/source/blender/python/api2_2x/doc/Curve.py
+++ b/source/blender/python/api2_2x/doc/Curve.py
@@ -73,6 +73,7 @@ class Curve:
@cvar loc: The Curve Data location(from the center).
@cvar rot: The Curve Data rotation(from the center).
@cvar size: The Curve Data size(from the center).
+ @cvar bevob: The Curve Bevel Object
"""
def getName():
@@ -319,6 +320,23 @@ class Curve:
@return: list of Material Objects assigned to the Curve.
"""
+ def getBevOb():
+ """
+ Returns the Bevel Object (BevOb) assigned to the Curve.
+ @rtype: Blender Object or PyNone
+ @return: Bevel Object (BevOb) assigned to the Curve.
+ """
+
+ def setBevOb( object ):
+ """
+ Assign a Bevel Object (BevOb) to the Curve. Passing None as the object parameter removes the bevel.
+ @rtype: PyNone
+ @return: PyNone
+ @type object: Curve type Blender Object
+ @param object: Blender Object to assign as Bevel Object (BevOb)
+ @raise TypeError: throws exception if the parameter is not a Curve type Blender Object or PyNone
+ """
+
def update():
"""
Updates display list for a Curve.