diff options
author | Willian Padovani Germano <wpgermano@gmail.com> | 2004-06-15 08:16:30 +0400 |
---|---|---|
committer | Willian Padovani Germano <wpgermano@gmail.com> | 2004-06-15 08:16:30 +0400 |
commit | 467311ad347d4c89f45e209985f934d1f9077faa (patch) | |
tree | 18db1b14446c5a5cfbbe9ab54bd332eeddb380c6 /source/blender/python/api2_2x/Scene.c | |
parent | 317e067ecb91c2127c12cee3808a5bb2402b82e4 (diff) |
- New script:
Wim Van Hoydonck contributed the famous Knife script (put under Modifiers group) developed by Stefano Selleri and himself (thank to both!)
- Added helper function Blender.sys.makename, updated docs and script ac3d_export to use it (shall update other exporters too):
this function is just a simple helper to format a filename as needed (change extension, strip dirname, it defaults to use G.sce as path).
- Added a test method: Blender.Scene.getScriptlinks(eventName):
just testing, if this path proves useful other functions will be added and made general, for objects, etc.
Diffstat (limited to 'source/blender/python/api2_2x/Scene.c')
-rw-r--r-- | source/blender/python/api2_2x/Scene.c | 56 |
1 files changed, 55 insertions, 1 deletions
diff --git a/source/blender/python/api2_2x/Scene.c b/source/blender/python/api2_2x/Scene.c index 8fa1802fe24..218610a67e5 100644 --- a/source/blender/python/api2_2x/Scene.c +++ b/source/blender/python/api2_2x/Scene.c @@ -37,6 +37,7 @@ #include <BSE_headerbuttons.h> /* for copy_scene */ #include <BIF_drawscene.h> /* for set_scene */ #include <BIF_space.h> /* for copy_view3d_lock() */ +#include <DNA_scriptlink_types.h> #include <MEM_guardedalloc.h> /* for MEM_callocN */ #include <mydevice.h> /* for #define REDRAW */ @@ -97,6 +98,7 @@ static PyObject *Scene_getChildren(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); +static PyObject *Scene_getScriptlinks(BPy_Scene *self, PyObject *args); //deprecated methods static PyObject *Scene_currentFrame(BPy_Scene *self, PyObject *args); @@ -140,6 +142,9 @@ static PyMethodDef BPy_Scene_methods[] = { "() - Return list of all objects linked to scene self"}, {"getCurrentCamera", (PyCFunction)Scene_getCurrentCamera, METH_NOARGS, "() - Return current active Camera"}, + {"getScriptlinks", (PyCFunction)Scene_getScriptlinks, METH_VARARGS, + "(eventname) - Get a list of this scene's scriptlinks (Text names) of the given type\n" + "(eventname) - string: FrameChanged, OnLoad or Redraw."}, {"setCurrentCamera", (PyCFunction)Scene_setCurrentCamera, METH_VARARGS, "() - Set the currently active Camera"}, //DEPRECATED @@ -693,7 +698,7 @@ static PyObject *Scene_setCurrentCamera (BPy_Scene *self, PyObject *args) { Object *object; BPy_Object *cam_obj; - Scene *scene = self->scene; + Scene *scene = self->scene; if (!scene) return EXPP_ReturnPyObjError (PyExc_RuntimeError, @@ -725,6 +730,55 @@ static PyObject *Scene_getRenderingContext (BPy_Scene *self) return RenderData_CreatePyObject(self->scene); } + +/* Scene.getScriptlinks */ +static PyObject *Scene_getScriptlinks (BPy_Scene *self, PyObject *args) +{ + Scene *scene = self->scene; + char *eventname = NULL; + int event = 0; + ScriptLink *slink = &(scene)->scriptlink; + + if (!scene) + return EXPP_ReturnPyObjError (PyExc_RuntimeError, + "Blender Scene was deleted!"); + + if (!PyArg_ParseTuple(args, "s", &eventname)) + return EXPP_ReturnPyObjError (PyExc_TypeError, + "expected event name (string) as argument"); + + if (!strcmp(eventname, "FrameChanged")) + event = SCRIPT_FRAMECHANGED; + else if (!strcmp(eventname, "OnLoad")) + event = SCRIPT_ONLOAD; + else if (!strcmp(eventname, "Redraw")) + event = SCRIPT_REDRAW; + else + return EXPP_ReturnPyObjError (PyExc_AttributeError, + "unknown event"); + + /* actually !scriptlink shouldn't happen ... */ + if (!slink || !slink->totscript) { + Py_INCREF(Py_None); + return Py_None; + } + else { + PyObject *list = PyList_New(0); + int i; + + if (!list) + return EXPP_ReturnPyObjError (PyExc_MemoryError, + "couldn't create PyList!"); + + for (i = 0; i < slink->totscript; i++) { + if ((slink->flag[i] == event) && slink->scripts[i]) + PyList_Append(list, PyString_FromString(slink->scripts[i]->name+2)); + } + + return list; + } +} + /*****************************************************************************/ // DEPRECATED /*****************************************************************************/ |