From e6f4bd6bafd2dd93ea7d03cc9c5296df152195b6 Mon Sep 17 00:00:00 2001 From: Ken Hughes Date: Tue, 4 Jul 2006 00:08:40 +0000 Subject: [PATCH] ===Python API=== Plumiferos request: added sceneRender.set attribute, which give access to the Render "Set" link for scenes. Always wondered what that button was for. --- source/blender/python/api2_2x/doc/Render.py | 4 ++ source/blender/python/api2_2x/sceneRender.c | 49 +++++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/source/blender/python/api2_2x/doc/Render.py b/source/blender/python/api2_2x/doc/Render.py index 00708295bf8..4fa6d2945b0 100644 --- a/source/blender/python/api2_2x/doc/Render.py +++ b/source/blender/python/api2_2x/doc/Render.py @@ -268,6 +268,10 @@ class RenderData: @ivar mapNew: New mapping value (in frames). Values are clamped to the range [1,900]. @type mapNew: int + @ivar set: The scene linked as a set to this scene. Values are an existing + scene or None (setting to None clears the set). The scene argument cannot + cause a circular link. + @type set: BPy_Scene or None """ def currentFrame(frame = None): diff --git a/source/blender/python/api2_2x/sceneRender.c b/source/blender/python/api2_2x/sceneRender.c index 22dea4fc60b..b35f81dca8a 100644 --- a/source/blender/python/api2_2x/sceneRender.c +++ b/source/blender/python/api2_2x/sceneRender.c @@ -38,6 +38,7 @@ struct View3D; /* keep me up here */ #include "BKE_image.h" #include "BKE_global.h" #include "BKE_screen.h" +#include "BKE_scene.h" #include "BIF_drawscene.h" #include "BIF_renderwin.h" @@ -51,6 +52,8 @@ struct View3D; /* keep me up here */ #include "blendef.h" #include "gen_utils.h" +#include "Scene.h" + /* local defines */ #define PY_NONE 0 #define PY_LOW 1 @@ -1502,6 +1505,7 @@ static int RenderData_setFloatAttrClamp( BPy_RenderData *self, PyObject *value, max = 5.0f; param = &self->renderContext->blurfac; break; + default: return EXPP_ReturnIntError( PyExc_RuntimeError, "undefined type constant in RenderData_setFloatAttrClamp" ); } @@ -1981,6 +1985,47 @@ static int RenderData_setMapNew( BPy_RenderData *self, PyObject *value ) return result; } +static PyObject *RenderData_getSet( BPy_RenderData *self ) +{ + if( self->scene->set ) + return Scene_CreatePyObject( self->scene->set ); + Py_RETURN_NONE; +} + +static int RenderData_setSet( BPy_RenderData *self, PyObject *value ) +{ + BPy_Scene *sc; + + /* if "None", delete the link to the scene */ + if( value == Py_None ) { + self->scene->set = NULL; + return 0; + } + + /* be sure argument is a Scene */ + if( !BPy_Scene_Check( value ) ) + return EXPP_ReturnIntError( PyExc_TypeError, + "expected Scene as argument" ); + + /* check for attempt to link to ourselves */ + sc = (BPy_Scene *)value; + if( self->scene == sc->scene ) + return EXPP_ReturnIntError( PyExc_ValueError, + "cannot link a scene to itself" ); + + /* + * Accept the set link, then check for a circular link. If circular link + * exists, scene_check_setscene() sets self->scene->set to NULL. + */ + + self->scene->set = sc->scene; + if( !scene_check_setscene( self->scene ) ) + return EXPP_ReturnIntError( PyExc_ValueError, + "linking scene would create a cycle" ); + + return 0; +} + /***************************************************************************/ /* BPy_RenderData attribute def */ /***************************************************************************/ @@ -2196,6 +2241,10 @@ static PyGetSetDef BPy_RenderData_getseters[] = { (getter)RenderData_getMapNew, (setter)RenderData_setMapNew, "New mapping value (in frames)", NULL}, + {"set", + (getter)RenderData_getSet, (setter)RenderData_setSet, + "Scene link 'set' value", + NULL}, {NULL,NULL,NULL,NULL,NULL} };