Index: source/blender/python/api2_2x/Object.c =================================================================== RCS file: /cvsroot/bf-blender/blender/source/blender/python/api2_2x/Object.c,v retrieving revision 1.73 diff -u -r1.73 Object.c --- source/blender/python/api2_2x/Object.c 20 May 2004 06:26:43 -0000 1.73 +++ source/blender/python/api2_2x/Object.c 30 May 2004 12:02:19 -0000 @@ -36,8 +36,6 @@ #include "Object.h" #include "NLA.h" #include "blendef.h" -#include "DNA_scene_types.h" -#include "BSE_edit.h" /*****************************************************************************/ /* Python API function prototypes for the Blender module. */ @@ -111,6 +109,7 @@ static PyObject *Object_getType (BPy_Object *self); static PyObject *Object_getBoundBox (BPy_Object *self); static PyObject *Object_getAction (BPy_Object *self); +static PyObject *Object_getSel (BPy_Object *self); static PyObject *Object_makeDisplayList (BPy_Object *self); static PyObject *Object_link (BPy_Object *self, PyObject *args); static PyObject *Object_makeParent (BPy_Object *self, PyObject *args); @@ -127,6 +126,7 @@ static PyObject *Object_setSize (BPy_Object *self, PyObject *args); static PyObject *Object_setTimeOffset (BPy_Object *self, PyObject *args); static PyObject *Object_shareFrom (BPy_Object *self, PyObject *args); +static PyObject *Object_setSel (BPy_Object *self, PyObject *args); /*****************************************************************************/ /* Python BPy_Object methods table: */ @@ -151,6 +151,8 @@ "Returns the object draw type"}, {"getAction", (PyCFunction)Object_getAction, METH_NOARGS, "Returns the active action for this object"}, + {"getSel", (PyCFunction)Object_getSel, METH_NOARGS, + "Return a 1/0 depending on weather the object is selected"}, {"getEuler", (PyCFunction)Object_getEuler, METH_NOARGS, "Returns the object's rotation as Euler rotation vector\n\ (rotX, rotY, rotZ)"}, @@ -224,6 +226,8 @@ {"shareFrom", (PyCFunction)Object_shareFrom, METH_VARARGS, "Link data of self with object specified in the argument. This\n\ works only if self and the object specified are of the same type."}, + {"setSel", (PyCFunction)Object_setSel, METH_VARARGS, + "Set the selected state of the object 1/0."}, {"setIpo", (PyCFunction)Object_setIpo, METH_VARARGS, "(Blender Ipo) - Sets the object's ipo"}, {"clearIpo", (PyCFunction)Object_clearIpo, METH_NOARGS, @@ -754,6 +758,29 @@ } } + +static PyObject *Object_getSel (BPy_Object *self) +{ + Base *base; + base= FIRSTBASE; + + PyObject *sel; + + while (base) { + if (base->object == self->object) + { + if (base->flag & SELECT) { + sel = Py_BuildValue ("b", 1); + } else { + sel = Py_BuildValue ("b", 0); + } + return sel; + } + base= base->next; + } +} + + static PyObject *Object_getDrawType (BPy_Object *self) { PyObject *attr = Py_BuildValue ("b", self->object->dt); @@ -1350,6 +1377,7 @@ return (Py_None); } + static PyObject *Object_setIpo(BPy_Object *self, PyObject *args) { PyObject *pyipo = 0; @@ -1590,6 +1618,42 @@ return (Py_None); } + + +static PyObject *Object_setSel (BPy_Object *self, PyObject *args) +{ + Base *base; + base= FIRSTBASE; + + int sel; + + if (!PyArg_ParseTuple (args, "i", &sel)) + return EXPP_ReturnPyObjError + (PyExc_TypeError, "expected an int, 0 or 1"); + + while (base) { + if (base->object == self->object) + { + if (sel == 1) + { + base->flag |= SELECT; + self->object->flag= base->flag; + } else { + base->flag &= ~SELECT; + self->object->flag= base->flag; + } + Py_INCREF (Py_None); + return (Py_None); + } + base= base->next; + } + + countall(); + + +} + + /*****************************************************************************/ /* Function: Object_CreatePyObject */ /* Description: This function will create a new BlenObject from an existing */ @@ -1793,7 +1857,9 @@ return (Py_BuildValue ("b", object->dtx)); if (StringEqual (name, "name")) return (Py_BuildValue ("s", object->id.name+2)); - + if (StringEqual (name, "sel")) + return (Object_getSel (obj)); + /* not an attribute, search the methods table */ return Py_FindMethod(BPy_Object_methods, (PyObject *)obj, name); } @@ -2002,7 +2068,15 @@ else return (0); } - + + if (StringEqual (name, "sel")) + { + if (Object_setSel (obj, valtuple) != Py_None) + return (-1); + else + return (0); + } + printf ("Unknown variable.\n"); return (0); } Index: source/blender/python/api2_2x/doc/Object.py =================================================================== RCS file: /cvsroot/bf-blender/blender/source/blender/python/api2_2x/doc/Object.py,v retrieving revision 1.16 diff -u -r1.16 Object.py --- source/blender/python/api2_2x/doc/Object.py 20 May 2004 07:21:07 -0000 1.16 +++ source/blender/python/api2_2x/doc/Object.py 30 May 2004 12:02:21 -0000 @@ -131,12 +131,11 @@ @cvar EffZ: The Z effector coordinate of the object. Only applies to IKA. @cvar Layer: The object layer. This value is a bitmask with one position set for each of the 20 possible layers starting from the low order bit. - The easiest way to deal with these values in in hexadecimal notation. - Example:: - ob.Layer = 0x04 # sets layer 3 ( bit pattern 0100 ) - - After setting the Layer value, call Blender.Redraw( -1 ) to update the - interface. + The easiest way to deal with these values in in hexadecimal notation. + Example:: + ob.Layer = 0x04 # sets layer 3 ( bit pattern 0100 ) + After setting the Layer value, call Blender.Redraw( -1 ) to update the + interface. @cvar parent: The parent object of the object. (Read-only) @cvar track: The object tracking this object. (Read-only) @cvar data: The data of the object. (Read-only) @@ -152,6 +151,7 @@ of: 2 - axis, 4 - texspace, 8 - drawname, 16 - drawimage, 32 - drawwire. @cvar name: The name of the object. + @cvar sel: The selection of the object, 1/0. """ def buildParts(): @@ -163,7 +163,7 @@ def clearIpo(): """ Unlinks the ipo from this object. - @return: True if there was an ipo linked or False otherwise. + """ def clrParent(mode = 0, fast = 0): @@ -346,6 +346,12 @@ Blender.Redraw() """ + def getSel(): + """ + Returns the objects selection state as 1 or 0 + @rtype: int + @return: Objects selection state as 1 or 0 + """ def link(object): """ @@ -468,13 +474,22 @@ @type timeOffset: float @param timeOffset: The new time offset for the object's animation. """ - + def shareFrom(object): """ Link data of self with object specified in the argument. This works only if self and the object specified are of the same type. @type object: Blender Object @param object: A Blender Object of the same type. + """ + + def setSel(boolean): + """ + Sets the object's selection state. + @type boolean: Integer + @param boolean: A sum of the following: + - 0 - unselected + - 1 - selected """ def getBoundBox():