Page MenuHome

Scene_getActive.txt

Scene_getActive.txt

Index: source/blender/python/api2_2x/Scene.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/python/api2_2x/Scene.c,v
retrieving revision 1.29
diff -u -p -r1.29 Scene.c
--- source/blender/python/api2_2x/Scene.c 21 Apr 2005 19:44:52 -0000 1.29
+++ source/blender/python/api2_2x/Scene.c 6 May 2005 02:10:09 -0000
@@ -102,6 +102,7 @@ static PyObject *Scene_update( BPy_Scene
static PyObject *Scene_link( BPy_Scene * self, PyObject * args );
static PyObject *Scene_unlink( BPy_Scene * self, PyObject * args );
static PyObject *Scene_getChildren( BPy_Scene * self );
+static PyObject *Scene_getActive( BPy_Scene * self );
static PyObject *Scene_getCurrentCamera( BPy_Scene * self );
static PyObject *Scene_setCurrentCamera( BPy_Scene * self, PyObject * args );
static PyObject *Scene_getRenderingContext( BPy_Scene * self );
@@ -146,6 +147,8 @@ static PyMethodDef BPy_Scene_methods[] =
"(obj) - Unlink Object obj from this scene"},
{"getChildren", ( PyCFunction ) Scene_getChildren, METH_NOARGS,
"() - Return list of all objects linked to scene self"},
+ {"getActive", ( PyCFunction ) Scene_getActive, METH_NOARGS,
+ "() - Return the active objects linked to scene self"},
{"getCurrentCamera", ( PyCFunction ) Scene_getCurrentCamera,
METH_NOARGS,
"() - Return current active Camera"},
@@ -838,6 +841,37 @@ static PyObject *Scene_getChildren( BPy_
return pylist;
}
+
+
+//-----------------------Scene.getActive()-----------------------------
+static PyObject *Scene_getActive( BPy_Scene * self )
+{
+ Scene *scene = self->scene;
+ PyObject *bpy_obj;
+ Object *object;
+
+ if( !scene )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "Blender Scene was deleted!" );
+
+ object= ((scene->basact)? (scene->basact->object) : 0);
+
+ if(object != 0) {
+ bpy_obj = M_Object_Get( Py_None,
+ Py_BuildValue( "(s)",
+ object->id.name + 2 ) );
+
+ if( !bpy_obj )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't create new object wrapper" );
+ return bpy_obj;
+
+ } else { /* No basact, return None */
+ Py_INCREF( Py_None ); /* none found */
+ return Py_None;
+ }
+}
+
//-----------------------Scene.getCurrentCamera()------------------------
static PyObject *Scene_getCurrentCamera( BPy_Scene * self )
Index: source/blender/python/api2_2x/doc/Scene.py
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/python/api2_2x/doc/Scene.py,v
retrieving revision 1.12
diff -u -p -r1.12 Scene.py
--- source/blender/python/api2_2x/doc/Scene.py 21 Apr 2005 19:44:52 -0000 1.12
+++ source/blender/python/api2_2x/doc/Scene.py 6 May 2005 02:10:10 -0000
@@ -189,6 +189,14 @@ class Scene:
particular scene.
"""
+ def getActive():
+ """
+ Get the active object for this Scene (if any).
+ @rtype: Blender Object
+ @return: The active object for this scene.
+ @note: The active object does not have to be selected, as is often assumed with Object.GetSelected()[0].
+ """
+
def getCurrentCamera():
"""
Get the currently active Camera for this Scene.

File Metadata

Mime Type
text/x-diff
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
73/09/f79541f98399fe6e817d8c6a91fc

Event Timeline