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:
authorWillian Padovani Germano <wpgermano@gmail.com>2005-02-09 18:53:35 +0300
committerWillian Padovani Germano <wpgermano@gmail.com>2005-02-09 18:53:35 +0300
commit34977b8937e7e990b35d3795dc35740e8991fb9c (patch)
treebcac546da525d593763fc49396e739bc34c5dc6e /source/blender/python/api2_2x/Object.c
parent05bf482f6a50bd711fc6bb7ad986919741d478ae (diff)
BPython:
- applied Campbell Barton's patch for access to Oops location and selection of materials, mesh data and objects, slightly modified. Thanks, Campbell; - got rid of warnings in many files, hopefully not introducing any other during the process. Mostly this was done: 1) new EXPP_incr_ret_True/False functions were added and used instead of "Py_INCREF(Py_True/False); return Py_True/False;". Currently at least the functions use the fact that PyTrue/False == 1/0 and use 1 and 0 to avoid the warnings. 2) Filling of certain types structs got 0's added for all not defined data and methods. This is surely Python version specific, since these structs can change size and content at each major version number Python update.
Diffstat (limited to 'source/blender/python/api2_2x/Object.c')
-rw-r--r--source/blender/python/api2_2x/Object.c48
1 files changed, 37 insertions, 11 deletions
diff --git a/source/blender/python/api2_2x/Object.c b/source/blender/python/api2_2x/Object.c
index 97476eb1fe0..b400a059781 100644
--- a/source/blender/python/api2_2x/Object.c
+++ b/source/blender/python/api2_2x/Object.c
@@ -51,6 +51,9 @@
#include "Lattice.h"
#include "modules.h"
+/* only used for oops location get/set at the moment */
+#include "DNA_oops_types.h"
+#include "DNA_space_types.h"
/*****************************************************************************/
/* Python API function prototypes for the Blender module. */
@@ -340,6 +343,7 @@ PyTypeObject Object_Type = {
0, 0, 0, 0, 0, 0,
BPy_Object_methods, /* tp_methods */
0, /* tp_members */
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
};
/*****************************************************************************/
@@ -608,12 +612,10 @@ static PyObject *Object_clearIpo( BPy_Object * self )
id->us--;
ob->ipo = NULL;
- Py_INCREF( Py_True );
- return Py_True;
+ return EXPP_incr_ret_True();
}
- Py_INCREF( Py_False ); /* no ipo found */
- return Py_False;
+ return EXPP_incr_ret_False(); /* no ipo found */
}
static PyObject *Object_clrParent( BPy_Object * self, PyObject * args )
@@ -856,11 +858,9 @@ static PyObject *Object_isSelected( BPy_Object * self )
while( base ) {
if( base->object == self->object ) {
if( base->flag & SELECT ) {
- Py_INCREF( Py_True );
- return Py_True;
+ return EXPP_incr_ret_True();
} else {
- Py_INCREF( Py_False );
- return Py_False;
+ return EXPP_incr_ret_False();
}
}
base = base->next;
@@ -2221,6 +2221,20 @@ static PyObject *Object_getAttr( BPy_Object * obj, char *name )
return ( Py_BuildValue( "s", object->id.name + 2 ) );
if( StringEqual( name, "sel" ) )
return ( Object_isSelected( obj ) );
+ if (StringEqual (name, "oopsLoc")) {
+ if (G.soops) {
+ Oops *oops= G.soops->oops.first;
+ while(oops) {
+ if(oops->type==ID_OB) {
+ if ((Object *)oops->id == object) {
+ return (Py_BuildValue ("ff", oops->x, oops->y));
+ }
+ }
+ oops= oops->next;
+ }
+ }
+ return EXPP_incr_ret( Py_None );
+ }
/* not an attribute, search the methods table */
return Py_FindMethod( BPy_Object_methods, ( PyObject * ) obj, name );
@@ -2422,16 +2436,28 @@ static int Object_setAttr( BPy_Object * obj, char *name, PyObject * value )
else
return ( 0 );
}
-
if( StringEqual( name, "sel" ) ) {
if( Object_Select( obj, valtuple ) != Py_None )
return ( -1 );
else
return ( 0 );
}
+ if (StringEqual (name, "oopsLoc")) {
+ if (G.soops) {
+ Oops *oops= G.soops->oops.first;
+ while(oops) {
+ if(oops->type==ID_OB) {
+ if ((Object *)oops->id == object) {
+ return (!PyArg_ParseTuple (value, "ff", &(oops->x),&(oops->y)));
+ }
+ }
+ oops= oops->next;
+ }
+ }
+ return 0;
+ }
- printf( "Unknown variable.\n" );
- return ( 0 );
+ return EXPP_ReturnIntError( PyExc_KeyError, "attribute not found" );
}
/*****************************************************************************/