Index: source/blender/python/api2_2x/Window.c =================================================================== --- source/blender/python/api2_2x/Window.c (revision 12644) +++ source/blender/python/api2_2x/Window.c (working copy) @@ -61,6 +61,19 @@ #include "gen_utils.h" #include "Armature.h" +/* Pivot Types +-0 for Bounding Box Center; \n\ +-1 for 3D Cursor\n\ +-2 for Individual Centers\n\ +-3 for Median Point\n\ +-4 for Active Object"; */ + +#define PIVOT_BOUNDBOX 0 +#define PIVOT_CURSOR 1 +#define PIVOT_INDIVIDUAL 2 +#define PIVOT_MEDIAN 3 +#define PIVOT_ACTIVE 4 + /* See Draw.c */ extern int EXPP_disable_force_draw; extern void setcameratoview3d(void); @@ -106,6 +119,8 @@ static PyObject *M_Window_SetScreen( PyObject * self, PyObject * value ); static PyObject *M_Window_GetScreenInfo( PyObject * self, PyObject * args, PyObject * kwords ); +static PyObject *M_Window_SetPivot( PyObject * self, PyObject * args ); + PyObject *Window_Init( void ); @@ -287,6 +302,15 @@ 'win': window type, see Blender.Window.Types dict;\n\ 'id': area's id."; +static char M_Window_SetPivot_doc[] = + "(Pivot) - Set Pivot Mode for 3D Viewport:\n\ +Options are: \n\ +-PivotTypes.BOUNDBOX for Bounding Box Center; \n\ +-PivotTypes.CURSOR for 3D Cursor\n\ +-PivotTypes.INDIVIDUAL for Individual Centers\n\ +-PivotTypes.MEDIAN for Median Point\n\ +-PivotTypes.ACTIVE for Active Object"; + /*****************************************************************************/ /* Python method structure definition for Blender.Window module: */ /*****************************************************************************/ @@ -374,6 +398,8 @@ M_Window_SetScreen_doc}, {"GetScreenInfo", ( PyCFunction ) M_Window_GetScreenInfo, METH_VARARGS | METH_KEYWORDS, M_Window_GetScreenInfo_doc}, + {"SetPivot", ( PyCFunction ) M_Window_SetPivot, METH_VARARGS, + M_Window_SetPivot_doc}, {NULL, NULL, 0, NULL} }; @@ -1454,12 +1480,35 @@ return list; } +static PyObject *M_Window_SetPivot( PyObject * self, PyObject * args) + +{ + short pivot; + int ok; + pivot = 0; + + ok = PyArg_ParseTuple(args, "h", &pivot); + if( !ok ) return EXPP_ReturnPyObjError( PyExc_TypeError, + "One argument expected" ); + + if ( pivot > 4 || pivot < 0 ) + return EXPP_ReturnPyObjError( PyExc_AttributeError, + "Invalid argument, should be 0,1,2,3 or 4 " ); + + + if (G.vd) G.vd->around = pivot; + + Py_RETURN_NONE; +} + + + /*****************************************************************************/ /* Function: Window_Init */ /*****************************************************************************/ PyObject *Window_Init( void ) { - PyObject *submodule, *Types, *Qual, *MButs, *dict; + PyObject *submodule, *Types, *Qual, *MButs, *PivotTypes, *dict; submodule = Py_InitModule3( "Blender.Window", M_Window_methods, @@ -1472,6 +1521,7 @@ Types = PyConstant_New( ); Qual = PyConstant_New( ); MButs = PyConstant_New( ); + PivotTypes = PyConstant_New( ); if( Types ) { BPy_constant *d = ( BPy_constant * ) Types; @@ -1522,5 +1572,16 @@ PyModule_AddObject( submodule, "MButs", MButs ); } + if( PivotTypes ) { + BPy_constant *d = ( BPy_constant * ) PivotTypes; + + PyConstant_Insert(d, "BOUNDBOX", PyInt_FromLong( PIVOT_BOUNDBOX ) ); + PyConstant_Insert(d, "CURSOR", PyInt_FromLong( PIVOT_CURSOR ) ); + PyConstant_Insert(d, "MEDIAN", PyInt_FromLong( PIVOT_MEDIAN ) ); + PyConstant_Insert(d, "ACTIVE", PyInt_FromLong( PIVOT_ACTIVE ) ); + PyConstant_Insert(d, "INDIVIDUAL", PyInt_FromLong( PIVOT_INDIVIDUAL ) ); + + PyModule_AddObject( submodule, "PivotTypes", PivotTypes ); + } return submodule; }