diff --git a/source/blender/python/api2_2x/Object.c b/source/blender/python/api2_2x/Object.c index 45cce46..3a13b6e 100644 --- a/source/blender/python/api2_2x/Object.c +++ b/source/blender/python/api2_2x/Object.c @@ -141,6 +141,14 @@ struct rctf; #define PFIELD_MAGNET 3 #define PFIELD_WIND 4 +#define EMPTY_ARROWS 1 +#define EMPTY_PLAINAXES 2 +#define EMPTY_CIRCLE 3 +#define EMPTY_SINGLEARROW 4 +#define EMPTY_CUBE 5 +#define EMPTY_SPHERE 6 +#define EMPTY_CONE 7 + enum obj_consts { EXPP_OBJ_ATTR_LOC_X = 0, EXPP_OBJ_ATTR_LOC_Y, @@ -204,6 +212,7 @@ enum obj_consts { EXPP_OBJ_ATTR_SB_INSPRING, EXPP_OBJ_ATTR_SB_INFRICT, + EXPP_OBJ_ATTR_EMPTY_DRAWTYPE }; #define EXPP_OBJECT_DRAWSIZEMIN 0.01f @@ -351,6 +360,7 @@ static PyObject *Object_getData(BPy_Object *self, PyObject *args, PyObject *kwd) static PyObject *Object_getDeltaLocation( BPy_Object * self ); static PyObject *Object_getDrawMode( BPy_Object * self ); static PyObject *Object_getDrawType( BPy_Object * self ); +static PyObject *Object_getEmptyShape( BPy_Object * self ); static PyObject *Object_GetEuler( BPy_Object * self, PyObject * args ); static PyObject *Object_getInverseMatrix( BPy_Object * self ); static PyObject *Object_getIpo( BPy_Object * self ); @@ -385,6 +395,7 @@ static PyObject *Object_getEffects( BPy_Object * self ); 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_SetEmptyShape( BPy_Object * self, PyObject * args ); static PyObject *Object_SetEuler( BPy_Object * self, PyObject * args ); static PyObject *Object_SetMatrix( BPy_Object * self, PyObject * args ); static PyObject *Object_SetIpo( BPy_Object * self, PyObject * args ); @@ -503,6 +514,8 @@ If 'name_only' is nonzero or True, only the name of the datablock is returned"}, "Returns the object draw modes"}, {"getDrawType", ( PyCFunction ) Object_getDrawType, METH_NOARGS, "Returns the object draw type"}, + {"getEmptyShape", ( PyCFunction ) Object_getEmptyShape, METH_NOARGS, + "Returns the empty's drawing shape"}, {"getAction", ( PyCFunction ) Object_getAction, METH_NOARGS, "Returns the active action for this object"}, {"evaluatePose", ( PyCFunction ) Object_evaluatePose, METH_VARARGS, @@ -703,6 +716,9 @@ Possible arguments (provide as strings):\n\ {"setDrawType", ( PyCFunction ) Object_SetDrawType, METH_VARARGS, "Sets the object's drawing type. The argument must be one of:\n\ 1: Bounding box\n2: Wire\n3: Solid\n4: Shaded\n5: Textured"}, + {"setEmptyShape", ( PyCFunction ) Object_SetEmptyShape, METH_VARARGS, + "Sets the empty's drawing shape. The argument must be one of:\n\ +1: Arrows\n2: Plain Axes\n3: Circle\n4: Single Arrow\n5: Cube\n6: Sphere\n7: Cone"}, {"setEuler", ( PyCFunction ) Object_SetEuler, METH_VARARGS, "Set the object's rotation according to the specified Euler\n\ angles. The argument must be a vector triple"}, @@ -2431,6 +2447,17 @@ static int Object_setDrawType( BPy_Object * self, PyObject * value ) OB_BOUNDBOX, OB_TEXTURE, 'b' ); } +static PyObject *Object_getEmptyShape( BPy_Object * self ) +{ + return PyInt_FromLong( (long)self->object->empty_drawtype ); +} + +static int Object_setEmptyShape( BPy_Object * self, PyObject * value ) +{ + return EXPP_setIValueRange( value, &self->object->empty_drawtype, + EMPTY_ARROWS, EMPTY_CONE, 'b' ); +} + static int Object_setEuler( BPy_Object * self, PyObject * args ) { float rot1, rot2, rot3; @@ -3758,6 +3785,9 @@ static PyObject *getIntAttr( BPy_Object *self, void *type ) case EXPP_OBJ_ATTR_DRAWTYPE: param = object->dt; break; + case EXPP_OBJ_ATTR_EMPTY_DRAWTYPE: + param = object->empty_drawtype; + break; case EXPP_OBJ_ATTR_PARENT_TYPE: param = object->partype; break; @@ -4938,6 +4968,10 @@ static PyGetSetDef BPy_Object_getseters[] = { (getter)getIntAttr, (setter)Object_setDrawType, "The object's drawing type", (void *)EXPP_OBJ_ATTR_DRAWTYPE}, + {"emptyShape", + (getter)getIntAttr, (setter)Object_setEmptyShape, + "The empty's drawing shape", + (void *)EXPP_OBJ_ATTR_EMPTY_DRAWTYPE}, {"parentType", (getter)getIntAttr, (setter)NULL, "The object's parent type", @@ -5538,6 +5572,24 @@ static PyObject *M_Object_IpoKeyTypesDict( void ) return M; } +static PyObject *M_Object_EmptyShapesDict( void ) +{ + PyObject *M = PyConstant_New( ); + + if( M ) { + BPy_constant *d = ( BPy_constant * ) M; + PyConstant_Insert( d, "ARROWS", PyInt_FromLong( EMPTY_ARROWS ) ); + PyConstant_Insert( d, "AXES", PyInt_FromLong( EMPTY_PLAINAXES ) ); + PyConstant_Insert( d, "CIRCLE", PyInt_FromLong( EMPTY_CIRCLE ) ); + PyConstant_Insert( d, "ARROW", PyInt_FromLong( EMPTY_SINGLEARROW ) ); + PyConstant_Insert( d, "CUBE", PyInt_FromLong( EMPTY_CUBE ) ); + PyConstant_Insert( d, "SPHERE", PyInt_FromLong( EMPTY_SPHERE ) ); + PyConstant_Insert( d, "CONE", PyInt_FromLong( EMPTY_CONE ) ); + } + return M; +} + + /*****************************************************************************/ /* Function: initObject */ /*****************************************************************************/ @@ -5552,6 +5604,7 @@ PyObject *Object_Init( void ) PyObject *RBFlagsDict = M_Object_RBFlagsDict( ); PyObject *RBShapesDict = M_Object_RBShapeBoundDict( ); PyObject *IpoKeyTypesDict = M_Object_IpoKeyTypesDict( ); + PyObject *EmptyShapesDict = M_Object_EmptyShapesDict( ); PyType_Ready( &Object_Type ) ; @@ -5596,7 +5649,9 @@ PyObject *Object_Init( void ) if( RBShapesDict ) PyModule_AddObject( module, "RBShapes", RBShapesDict ); if( IpoKeyTypesDict ) - PyModule_AddObject( module, "IpoKeyTypes", IpoKeyTypesDict ); + PyModule_AddObject( module, "IpoKeyTypes", IpoKeyTypesDict ); + if( EmptyShapesDict ) + PyModule_AddObject( module, "EmptyShapes", EmptyShapesDict ); /*Add SUBMODULES to the module*/ dict = PyModule_GetDict( module ); /*borrowed*/ @@ -5630,6 +5685,12 @@ static PyObject *Object_SetDrawType( BPy_Object * self, PyObject * args ) (setter)Object_setDrawType ); } +static PyObject *Object_SetEmptyShape( BPy_Object * self, PyObject * args ) +{ + return EXPP_setterWrapper( (void *)self, args, + (setter)Object_setEmptyShape ); +} + static PyObject *Object_SetMatrix( BPy_Object * self, PyObject * args ) { return EXPP_setterWrapper( (void *)self, args, diff --git a/source/blender/python/api2_2x/doc/Object.py b/source/blender/python/api2_2x/doc/Object.py index 2e4850a..46a562d 100644 --- a/source/blender/python/api2_2x/doc/Object.py +++ b/source/blender/python/api2_2x/doc/Object.py @@ -117,6 +117,10 @@ Example:: attribute. Only one type can be selected at a time. Values are BOX, SPHERE, CYLINDER, CONE, and POLYHEDERON +@type EmptyShapes: readonly dictionary +@var EmptyShapes: Constant dict used for with L{Object.emptyShape} attribute. + Only one type can be selected at a time. Values are + ARROW, ARROWS, AXES, CIRCLE, CONE, CUBE AND SPHERE """ def New (type, name='type'): @@ -525,6 +529,8 @@ class Object: @ivar drawType: The object's drawing type. See L{DrawTypes} constant dict for values. @type drawType: int + @ivar emptyShape: The empty's drawing shape. + See L{EmptyShapes} constant dict for values. @ivar parentType: The object's parent type. Read-only. See L{ParentTypes} constant dict for values. @type parentType: int @@ -768,6 +774,13 @@ class Object: - 5 - Textured """ + def getEmptyShape(): + """ + Returns the empty draw shape + @rtype: Integer + @return: A constant from L{EmptyShapes} + """ + def getEuler(space): """ @type space: string @@ -1103,6 +1116,13 @@ class Object: - 5 - Textured """ + def setEmptyShape(emptyshape): + """ + Sets the empty's draw shape + @type emptyshape: Integer + @param emptyshape: A constant from L{EmptyShapes} + """ + def setEuler(euler): """ Sets the object's localspace rotation according to the specified Euler angles.