Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2009-12-07 01:01:04 +0300
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2009-12-07 01:01:04 +0300
commit128f9730f2c63b85d397e9c09a612e806665c863 (patch)
treeb730a76c5eeb8c06ec12a08b87f3b9facd098312 /source/blender/freestyle/intern/python/BPy_Freestyle.cpp
parent092e708ee1ae5bf1dbf070144daf793540380d0e (diff)
Added Freestyle.getCurrentScene() to give access to the current scene
from within style modules. Calling this function is only valid within style modules. Calling it from the Python Interactive Console results in an error as follows: >>> import Freestyle >>> Freestyle.getCurrentScene() Traceback (most recent call last): File "<console>", line 1, in <module> TypeError: current scene not available >>>
Diffstat (limited to 'source/blender/freestyle/intern/python/BPy_Freestyle.cpp')
-rw-r--r--source/blender/freestyle/intern/python/BPy_Freestyle.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/source/blender/freestyle/intern/python/BPy_Freestyle.cpp b/source/blender/freestyle/intern/python/BPy_Freestyle.cpp
index bd5a5c8b38a..3e8572d07ae 100644
--- a/source/blender/freestyle/intern/python/BPy_Freestyle.cpp
+++ b/source/blender/freestyle/intern/python/BPy_Freestyle.cpp
@@ -33,6 +33,7 @@ extern "C" {
//static PyObject *Freestyle_testOutput( BPy_Freestyle * self );
+static PyObject *Freestyle_getCurrentScene( PyObject *self );
/*-----------------------Freestyle module doc strings--------------------------*/
@@ -42,6 +43,7 @@ static char module_docstring[] = "The Blender Freestyle module\n\n";
static PyMethodDef module_functions[] = {
// {"testOutput", ( PyCFunction ) Freestyle_testOutput, METH_NOARGS, "() - Return Curve Data name"},
+ {"getCurrentScene", ( PyCFunction ) Freestyle_getCurrentScene, METH_NOARGS, "() - Return the current scene."},
{NULL, NULL, 0, NULL}
};
@@ -99,6 +101,20 @@ PyObject *Freestyle_Init( void )
///////////////////////////////////////////////////////////////////////////////////////////
+#include "FRS_freestyle.h"
+#include "bpy_rna.h" /* pyrna_struct_CreatePyObject() */
+
+static PyObject *Freestyle_getCurrentScene( PyObject *self )
+{
+ if (!freestyle_scene) {
+ PyErr_SetString(PyExc_TypeError, "current scene not available");
+ return NULL;
+ }
+ PointerRNA ptr_scene;
+ RNA_pointer_create(NULL, &RNA_Scene, freestyle_scene, &ptr_scene);
+ return pyrna_struct_CreatePyObject(&ptr_scene);
+}
+
#ifdef __cplusplus
}
#endif