? blender ? blender_back ? config.opts ? extern/ode/dist/include/ode/config.h ? obj/linux-glibc2.3.2-i386 ? source/blender/python/api2_2x/Object.c_sel ? source/blender/python/api2_2x/doc/Armature.pyc ? source/blender/python/api2_2x/doc/BGL.pyc ? source/blender/python/api2_2x/doc/BPY_API_233 ? source/blender/python/api2_2x/doc/Blender.pyc ? source/blender/python/api2_2x/doc/Bone.pyc ? source/blender/python/api2_2x/doc/Camera.pyc ? source/blender/python/api2_2x/doc/Curve.pyc ? source/blender/python/api2_2x/doc/Draw.pyc ? source/blender/python/api2_2x/doc/Effect.pyc ? source/blender/python/api2_2x/doc/Image.pyc ? source/blender/python/api2_2x/doc/Ipo.pyc ? source/blender/python/api2_2x/doc/Lamp.pyc ? source/blender/python/api2_2x/doc/Lattice.pyc ? source/blender/python/api2_2x/doc/Library.pyc ? source/blender/python/api2_2x/doc/Material.pyc ? source/blender/python/api2_2x/doc/Mathutils.pyc ? source/blender/python/api2_2x/doc/Metaball.pyc ? source/blender/python/api2_2x/doc/NLA.pyc ? source/blender/python/api2_2x/doc/NMesh.pyc ? source/blender/python/api2_2x/doc/Noise.pyc ? source/blender/python/api2_2x/doc/Object.pyc ? source/blender/python/api2_2x/doc/Registry.pyc ? source/blender/python/api2_2x/doc/Render.pyc ? source/blender/python/api2_2x/doc/Scene.pyc ? source/blender/python/api2_2x/doc/Sys.pyc ? source/blender/python/api2_2x/doc/Text.pyc ? source/blender/python/api2_2x/doc/Texture.pyc ? source/blender/python/api2_2x/doc/Types.pyc ? source/blender/python/api2_2x/doc/Window.pyc ? source/blender/python/api2_2x/doc/World.pyc 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 31 May 2004 10:32:01 -0000 @@ -111,6 +111,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_isSelected (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 +128,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_Select (BPy_Object *self, PyObject *args); /*****************************************************************************/ /* Python BPy_Object methods table: */ @@ -151,6 +153,8 @@ "Returns the object draw type"}, {"getAction", (PyCFunction)Object_getAction, METH_NOARGS, "Returns the active action for this object"}, + {"isSelected", (PyCFunction)Object_isSelected, 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 +228,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."}, + {"Select", (PyCFunction)Object_Select, 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 +760,29 @@ } } + +static PyObject *Object_isSelected (BPy_Object *self) +{ + Base *base; + + base= FIRSTBASE; + while (base) { + if (base->object == self->object) { + if (base->flag & SELECT) { + Py_INCREF (Py_True); + return Py_True; + } else { + Py_INCREF (Py_False); + return Py_False; + } + } + base= base->next; + } + return (PythonReturnErrorObject (PyExc_RuntimeError, + "Internal error: could not find objects selection state")); +} + + static PyObject *Object_getDrawType (BPy_Object *self) { PyObject *attr = Py_BuildValue ("b", self->object->dt); @@ -1350,6 +1379,7 @@ return (Py_None); } + static PyObject *Object_setIpo(BPy_Object *self, PyObject *args) { PyObject *pyipo = 0; @@ -1590,6 +1620,41 @@ return (Py_None); } + + +static PyObject *Object_Select (BPy_Object *self, PyObject *args) +{ + Base *base; + int sel; + + base= FIRSTBASE; + 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; + } + break; + } + base= base->next; + } + + countall(); + + Py_INCREF (Py_None); + return (Py_None); +} + + /*****************************************************************************/ /* Function: Object_CreatePyObject */ /* Description: This function will create a new BlenObject from an existing */ @@ -1793,7 +1858,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_isSelected (obj)); + /* not an attribute, search the methods table */ return Py_FindMethod(BPy_Object_methods, (PyObject *)obj, name); } @@ -2002,7 +2069,15 @@ else return (0); } - + + if (StringEqual (name, "sel")) + { + if (Object_Select (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 31 May 2004 10:32:03 -0000 @@ -1,4 +1,4 @@ -# Blender.Object module and the Object PyType object + # Blender.Object module and the Object PyType object """ The Blender.Object submodule @@ -152,6 +152,7 @@ of: 2 - axis, 4 - texspace, 8 - drawname, 16 - drawimage, 32 - drawwire. @cvar name: The name of the object. + @cvar sel: The selection state of the object, 1/0. """ def buildParts(): @@ -238,7 +239,13 @@ @rtype: Ipo @return: the wrapped ipo or None. """ - + def isSelected(): + """ + Returns the objects selection state as a boolean value True or False. + @rtype: Boolean + @return: Selection state as True or False + """ + def getLocation(): """ Returns the object's location (x, y, z). @@ -476,7 +483,16 @@ @type object: Blender Object @param object: A Blender Object of the same type. """ - + + def Select(boolean): + """ + Sets the object's selection state. + @type boolean: Integer + @param boolean: + - 0 - unselected + - 1 - selected + """ + def getBoundBox(): """ Returns the bounding box of this object. This works for meshes (out of