Python API
authorKen Hughes <khughes@pacific.edu>
Wed, 16 Jan 2008 03:02:54 +0000 (03:02 +0000)
committerKen Hughes <khughes@pacific.edu>
Wed, 16 Jan 2008 03:02:54 +0000 (03:02 +0000)
----------
Added RenderData.activeLayer attribute, lets user access the active
rendering layer.  Also corrected description of RenderData.freeImages
attribute.

Note: doesn't seem like there is any support in the python API for accessing
the renderlayers settings....

source/blender/python/api2_2x/doc/Render.py
source/blender/python/api2_2x/sceneRender.c

index d75e07de8e3c65e7a4236b6d2b3f89f9b2cd1927..7ab3d7b90a9b43c506dd48abc406b91d01d78c9b 100644 (file)
@@ -246,10 +246,12 @@ class RenderData:
   @type extensions: boolean
   @ivar compositor: 'Do Compositor' enabled.
   @type compositor: boolean
-  @ivar freeImages: 'Do Compositor' enabled.
+  @ivar freeImages: Texture images are freed after render.
   @type freeImages: boolean
   @ivar singleLayer: Only render the active layer.
   @type singleLayer: boolean
+  @ivar activeLayer: The active render layer.  Must be in range[0,num render layers-1]
+  @type activeLayer: int
   @ivar saveBuffers: Save render buffers to disk while rendering, saves memory.
   @type saveBuffers: boolean
   @ivar compositeFree: Free nodes that are not used while composite.
index a160db1ad222ed6f3e07945cb21659a8c49ea931..66e2563f1e14a5fbffd73b9df84d62b9ec63fc13 100644 (file)
@@ -1,5 +1,5 @@
 /* 
- * $Id: sceneRender.c 12813 2007-12-07 09:51:02Z campbellbarton $
+ * $Id$
  *
  * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
  *
@@ -2357,6 +2357,32 @@ static int RenderData_setThreads( BPy_RenderData *self, PyObject *value )
        return 0;
 }
 
+PyObject *RenderData_getActiveLayer( BPy_RenderData * self )
+{
+       return PyInt_FromLong( (long) self->renderContext->actlay );
+}
+
+static int RenderData_setActiveLayer( BPy_RenderData *self, PyObject *value )
+{
+       int layer;
+       short nr;
+    SceneRenderLayer *srl;
+
+       if( !PyInt_Check( value ) )
+               return EXPP_ReturnIntError( PyExc_TypeError, "active layer must be an int" );
+
+       layer = PyInt_AsLong( value );
+    for(nr=0, srl= self->renderContext->layers.first; srl; srl= srl->next, nr++) {
+       }
+       if(layer >= nr)
+               return EXPP_ReturnIntError( PyExc_ValueError, "value larger than number of render layers" );
+
+       self->renderContext->actlay = layer;
+       EXPP_allqueue(REDRAWBUTSSCENE, 0);
+       EXPP_allqueue(REDRAWNODE, 0);
+       return 0;
+}
+
 /***************************************************************************/
 /* BPy_RenderData attribute def                                            */
 /***************************************************************************/
@@ -2600,6 +2626,11 @@ static PyGetSetDef BPy_RenderData_getseters[] = {
         "Scene link 'set' value",
         NULL},
 
+       {"activeLayer",
+        (getter)RenderData_getActiveLayer, (setter)RenderData_setActiveLayer,
+        "Active rendering layer",
+        NULL},
+
        {"yafrayGIMethod",
         (getter)RenderData_getYafrayGIMethod, (setter)RenderData_setYafrayGIMethod,
         "Global illumination method",