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:
authorWillian Padovani Germano <wpgermano@gmail.com>2004-06-24 13:43:13 +0400
committerWillian Padovani Germano <wpgermano@gmail.com>2004-06-24 13:43:13 +0400
commit61efb63b0c7e4bdb62d2d4007205db34ed627623 (patch)
treea1ba4ec29dbd028b9bd930c81d67284affcab3b9
parent5b57d007a4f123a23f704a8d4aff431588e439b7 (diff)
BPython:
- Added function Blender.Save(filename) to save .blend files. - Added scriptlink-related methods (get, clear, add) to Scene and Materials. Will still add method remove and add these methods to World, Object, Camera and Lamp. - Updates and small fixes in docs.
-rw-r--r--release/scripts/ac3d_import.py2
-rw-r--r--source/blender/python/api2_2x/Blender.c59
-rw-r--r--source/blender/python/api2_2x/Library.c9
-rw-r--r--source/blender/python/api2_2x/Material.c201
-rw-r--r--source/blender/python/api2_2x/Scene.c156
-rw-r--r--source/blender/python/api2_2x/doc/Blender.py18
-rw-r--r--source/blender/python/api2_2x/doc/Library.py2
-rw-r--r--source/blender/python/api2_2x/doc/Material.py31
-rw-r--r--source/blender/python/api2_2x/doc/NMesh.py2
-rw-r--r--source/blender/python/api2_2x/doc/Render.py33
-rw-r--r--source/blender/python/api2_2x/doc/Scene.py71
-rw-r--r--source/blender/python/api2_2x/gen_utils.c236
-rw-r--r--source/blender/python/api2_2x/gen_utils.h19
13 files changed, 580 insertions, 259 deletions
diff --git a/release/scripts/ac3d_import.py b/release/scripts/ac3d_import.py
index 16792f819bd..a9c855b4a0a 100644
--- a/release/scripts/ac3d_import.py
+++ b/release/scripts/ac3d_import.py
@@ -419,4 +419,4 @@ class AC3DImport:
def filesel_callback(filename):
test = AC3DImport(filename)
-Blender.Window.FileSelector(filesel_callback, "Import AC3D")
+Blender.Window.FileSelector(filesel_callback, "Import AC3D", "*.ac")
diff --git a/source/blender/python/api2_2x/Blender.c b/source/blender/python/api2_2x/Blender.c
index 5f3a857920e..f9629cf1d1e 100644
--- a/source/blender/python/api2_2x/Blender.c
+++ b/source/blender/python/api2_2x/Blender.c
@@ -34,7 +34,9 @@
#include <BIF_usiblender.h>
#include <BLI_blenlib.h>
+#include <BLO_writefile.h>
#include <BKE_global.h>
+#include <BKE_packedFile.h>
#include <BPI_script.h>
#include <BSE_headerbuttons.h>
#include <DNA_ID.h>
@@ -61,6 +63,7 @@ static PyObject *Blender_Redraw(PyObject *self, PyObject *args);
static PyObject *Blender_ReleaseGlobalDict(PyObject *self, PyObject *args);
static PyObject *Blender_Quit(PyObject *self);
static PyObject *Blender_Load(PyObject *self, PyObject *args);
+static PyObject *Blender_Save(PyObject *self, PyObject *args);
/*****************************************************************************/
/* The following string definitions are used for documentation strings. */
@@ -94,7 +97,7 @@ static char Blender_Quit_doc[] =
"() - Quit Blender. The current data is saved as 'quit.blend' before leaving.";
static char Blender_Load_doc[] =
-"(filename) - Load the given .blend file. If succesful, the script is ended\n\
+"(filename) - Load the given .blend file. If successful, the script is ended\n\
immediately.\n\
Notes:\n\
1 - () - an empty argument loads the default .B.blend file;\n\
@@ -104,6 +107,10 @@ Notes:\n\
4 - This function only works if the script where it's executed is the\n\
only one running.";
+static char Blender_Save_doc[] =
+"(filename) - Save a .blend file with the given filename.\n\
+(filename) - A file pathname that should not contain \".B.blend\" in it.";
+
/*****************************************************************************/
/* Python method structure definition. */
/*****************************************************************************/
@@ -113,6 +120,7 @@ static struct PyMethodDef Blender_methods[] = {
{"Redraw", Blender_Redraw, METH_VARARGS, Blender_Redraw_doc},
{"Quit", (PyCFunction)Blender_Quit, METH_NOARGS, Blender_Quit_doc},
{"Load", Blender_Load, METH_VARARGS, Blender_Load_doc},
+ {"Save", Blender_Save, METH_VARARGS, Blender_Save_doc},
{"ReleaseGlobalDict", &Blender_ReleaseGlobalDict,
METH_VARARGS, Blender_ReleaseGlobalDict_doc},
{NULL, NULL, 0, NULL}
@@ -330,6 +338,55 @@ static PyObject *Blender_Load(PyObject *self, PyObject *args)
return Py_None;
}
+static PyObject *Blender_Save(PyObject *self, PyObject *args)
+{
+ char *fname = NULL;
+ char savefname[FILE_MAXFILE];
+ int overwrite = 0, len = 0;
+ char *error = NULL;
+ Library *li;
+
+ if (!PyArg_ParseTuple(args, "s|i", &fname, &overwrite))
+ return EXPP_ReturnPyObjError(PyExc_TypeError,
+ "expected filename and optional int (overwrite flag) as arguments");
+
+ for (li = G.main->library.first; li; li = li->id.next) {
+ if (BLI_streq(li->name, fname)) {
+ return EXPP_ReturnPyObjError(PyExc_AttributeError,
+ "cannot overwrite used library");
+ }
+ }
+
+ /* for safety, any filename with .B.blend is considered the default one
+ * and not accepted here. */
+ if (strstr(fname, ".B.blend"))
+ return EXPP_ReturnPyObjError(PyExc_AttributeError,
+ "filename can't contain the substring \".B.blend\" in it.");
+
+ len = strlen(fname);
+
+ if (len > FILE_MAXFILE - 7) /* 6+1 for eventual .blend added below */
+ return EXPP_ReturnPyObjError(PyExc_AttributeError,
+ "filename is too long!");
+ else
+ BLI_strncpy(savefname, fname, len + 1);
+
+ if (!strstr(fname, ".blend"))
+ BLI_strncpy(savefname + len, ".blend", 7); /* 7: BLI_strncpy adds '\0'*/
+
+ if (BLI_exists(savefname) && !overwrite)
+ return EXPP_ReturnPyObjError(PyExc_AttributeError,
+ "file already exists and overwrite flag was not given.");
+
+ if (G.fileflags & G_AUTOPACK) packAll();
+
+ if (!BLO_write_file(savefname, G.fileflags, &error))
+ return EXPP_ReturnPyObjError(PyExc_SystemError, error);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
/*****************************************************************************/
/* Function: initBlender */
/*****************************************************************************/
diff --git a/source/blender/python/api2_2x/Library.c b/source/blender/python/api2_2x/Library.c
index 3b546d8f4f0..d281c21dbc4 100644
--- a/source/blender/python/api2_2x/Library.c
+++ b/source/blender/python/api2_2x/Library.c
@@ -36,12 +36,13 @@
#include <Python.h>
#include <stdio.h>
+#include <DNA_ID.h>
+#include <BKE_library.h> /* for all_local */
#include "BKE_displist.h" /* for set_displist_onlyzero */
#include "BKE_font.h" /* for text_to_curve */
-#include "BKE_library.h" /* for all_local */
-#include "BLO_readfile.h"
-#include "BLI_linklist.h"
-#include "MEM_guardedalloc.h"
+#include <BLO_readfile.h>
+#include <BLI_linklist.h>
+#include <MEM_guardedalloc.h>
#include "gen_utils.h"
#include "modules.h"
diff --git a/source/blender/python/api2_2x/Material.c b/source/blender/python/api2_2x/Material.c
index f2cfbfb23e3..81ea0dbba0f 100644
--- a/source/blender/python/api2_2x/Material.c
+++ b/source/blender/python/api2_2x/Material.c
@@ -383,6 +383,10 @@ static PyObject *Material_clearTexture(BPy_Material *self, PyObject *args);
static PyObject *Material_setColorComponent(BPy_Material *self, char *key,
PyObject *args);
+static PyObject *Material_getScriptLinks(BPy_Material *self, PyObject *args);
+static PyObject *Material_addScriptLink(BPy_Material *self, PyObject *args);
+static PyObject *Material_clearScriptLinks(BPy_Material *self);
+
/*****************************************************************************/
/* Python BPy_Material methods table: */
/*****************************************************************************/
@@ -500,9 +504,19 @@ static PyMethodDef BPy_Material_methods[] = {
{"setNRings", (PyCFunction)Material_setNRings, METH_VARARGS,
"(i) - Set Material's number of rings in halo - [0, 24]"},
{"setTexture", (PyCFunction)Material_setTexture, METH_VARARGS,
- "(n,tex,texco=0,mapto=0) - Set numbered texture to tex"},
+ "(n,tex,texco=0,mapto=0) - Set numbered texture to tex"},
{"clearTexture", (PyCFunction)Material_clearTexture, METH_VARARGS,
"(n) - Remove texture from numbered slot"},
+ {"getScriptLinks", (PyCFunction)Material_getScriptLinks, METH_VARARGS,
+ "(eventname) - Get a list of this material's scriptlinks (Text names) "
+ "of the given type\n"
+ "(eventname) - string: FrameChanged or Redraw."},
+ {"addScriptLink", (PyCFunction)Material_addScriptLink, METH_VARARGS,
+ "(text, evt) - Add a new material scriptlink.\n"
+ "(text) - string: an existing Blender Text name;\n"
+ "(evt) string: FrameChanged or Redraw."},
+ {"clearScriptLinks", (PyCFunction)Material_clearScriptLinks, METH_NOARGS,
+ "() - Delete all scriptlinks from this material."},
{NULL, NULL, 0, NULL}
};
@@ -892,32 +906,32 @@ static PyObject *Material_getNRings(BPy_Material *self)
static PyObject *Material_getTextures(BPy_Material *self)
{
- int i;
- struct MTex *mtex;
- PyObject *t[8];
- PyObject *tuple;
-
- /* build a texture list */
- for (i=0; i<8; ++i) {
- mtex = self->material->mtex[i];
-
- if (mtex) {
- t[i] = MTex_CreatePyObject (mtex);
- }
- else {
- Py_INCREF (Py_None);
- t[i] = Py_None;
- }
- }
-
- /* turn the array into a tuple */
- tuple = Py_BuildValue ("NNNNNNNN", t[0], t[1], t[2], t[3],
- t[4], t[5], t[6], t[7]);
+ int i;
+ struct MTex *mtex;
+ PyObject *t[8];
+ PyObject *tuple;
+
+ /* build a texture list */
+ for (i=0; i<8; ++i) {
+ mtex = self->material->mtex[i];
+
+ if (mtex) {
+ t[i] = MTex_CreatePyObject (mtex);
+ }
+ else {
+ Py_INCREF (Py_None);
+ t[i] = Py_None;
+ }
+ }
+
+ /* turn the array into a tuple */
+ tuple = Py_BuildValue ("NNNNNNNN", t[0], t[1], t[2], t[3],
+ t[4], t[5], t[6], t[7]);
if (!tuple)
return EXPP_ReturnPyObjError(PyExc_MemoryError,
"Material_getTextures: couldn't create PyTuple");
- return tuple;
+ return tuple;
}
static PyObject *Material_setIpo(BPy_Material *self, PyObject *args)
@@ -1396,61 +1410,100 @@ static PyObject *Material_setNRings(BPy_Material *self, PyObject *args)
static PyObject *Material_setTexture(BPy_Material *self, PyObject *args)
{
- int texnum;
- PyObject *pytex;
- Tex *bltex;
- int texco=TEXCO_ORCO, mapto=MAP_COL;
-
- if (!PyArg_ParseTuple(args, "iO!|ii", &texnum, &Texture_Type, &pytex,
- &texco, &mapto))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected int in [0,7] and Texture");
- if ((texnum<0) || (texnum>=8))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected int in [0,7] and Texture");
-
- bltex = Texture_FromPyObject (pytex);
-
- if (!self->material->mtex[texnum]) {
- /* there isn't an mtex for this slot so we need to make one */
- self->material->mtex[texnum] = add_mtex ();
- }
- else {
- /* we already had a texture here so deal with the old one first */
- self->material->mtex[texnum]->tex->id.us--;
- }
-
- self->material->mtex[texnum]->tex = bltex;
- id_us_plus (&bltex->id);
- self->material->mtex[texnum]->texco = texco;
- self->material->mtex[texnum]->mapto = mapto;
-
- Py_INCREF(Py_None);
- return Py_None;
+ int texnum;
+ PyObject *pytex;
+ Tex *bltex;
+ int texco=TEXCO_ORCO, mapto=MAP_COL;
+
+ if (!PyArg_ParseTuple(args, "iO!|ii", &texnum, &Texture_Type, &pytex,
+ &texco, &mapto))
+ return EXPP_ReturnPyObjError (PyExc_TypeError,
+ "expected int in [0,7] and Texture");
+ if ((texnum<0) || (texnum>=8))
+ return EXPP_ReturnPyObjError (PyExc_TypeError,
+ "expected int in [0,7] and Texture");
+
+ bltex = Texture_FromPyObject (pytex);
+
+ if (!self->material->mtex[texnum]) {
+ /* there isn't an mtex for this slot so we need to make one */
+ self->material->mtex[texnum] = add_mtex ();
+ }
+ else {
+ /* we already had a texture here so deal with the old one first */
+ self->material->mtex[texnum]->tex->id.us--;
+ }
+
+ self->material->mtex[texnum]->tex = bltex;
+ id_us_plus (&bltex->id);
+ self->material->mtex[texnum]->texco = texco;
+ self->material->mtex[texnum]->mapto = mapto;
+
+ Py_INCREF(Py_None);
+ return Py_None;
}
static PyObject *Material_clearTexture(BPy_Material *self, PyObject *args)
{
- int texnum;
- struct MTex *mtex;
-
- if (!PyArg_ParseTuple(args, "i", &texnum))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected int in [0,7]");
- if ((texnum<0) || (texnum>=8))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected int in [0,7]");
-
- mtex = self->material->mtex[texnum];
- if (mtex) {
- if (mtex->tex)
- mtex->tex->id.us--;
- MEM_freeN (mtex);
- self->material->mtex[texnum] = NULL;
- }
-
- Py_INCREF(Py_None);
- return Py_None;
+ int texnum;
+ struct MTex *mtex;
+
+ if (!PyArg_ParseTuple(args, "i", &texnum))
+ return EXPP_ReturnPyObjError (PyExc_TypeError,
+ "expected int in [0,7]");
+ if ((texnum<0) || (texnum>=8))
+ return EXPP_ReturnPyObjError (PyExc_TypeError,
+ "expected int in [0,7]");
+
+ mtex = self->material->mtex[texnum];
+ if (mtex) {
+ if (mtex->tex)
+ mtex->tex->id.us--;
+ MEM_freeN (mtex);
+ self->material->mtex[texnum] = NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+/* mat.addScriptLink */
+static PyObject *Material_addScriptLink (BPy_Material *self, PyObject *args)
+{
+ Material *mat = self->material;
+ ScriptLink *slink = NULL;
+
+ slink = &(mat)->scriptlink;
+
+ if (!EXPP_addScriptLink(slink, args, 0))
+ return EXPP_incr_ret (Py_None);
+ else return NULL;
+}
+
+/* mat.clearScriptLinks */
+static PyObject *Material_clearScriptLinks (BPy_Material *self)
+{
+ Material *mat = self->material;
+ ScriptLink *slink = NULL;
+
+ slink = &(mat)->scriptlink;
+
+ return EXPP_incr_ret(Py_BuildValue("i", EXPP_clearScriptLinks (slink)));
+}
+
+/* mat.getScriptLinks */
+static PyObject *Material_getScriptLinks (BPy_Material *self, PyObject *args)
+{
+ Material *mat = self->material;
+ ScriptLink *slink = NULL;
+ PyObject *ret = NULL;
+
+ slink = &(mat)->scriptlink;
+
+ ret = EXPP_getScriptLinks(slink, args, 0);
+
+ if (ret) return ret;
+ else return NULL;
}
/*****************************************************************************/
diff --git a/source/blender/python/api2_2x/Scene.c b/source/blender/python/api2_2x/Scene.c
index 218610a67e5..eb1536f2d1b 100644
--- a/source/blender/python/api2_2x/Scene.c
+++ b/source/blender/python/api2_2x/Scene.c
@@ -98,7 +98,9 @@ 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);
+static PyObject *Scene_getScriptLinks(BPy_Scene *self, PyObject *args);
+static PyObject *Scene_addScriptLink(BPy_Scene *self, PyObject *args);
+static PyObject *Scene_clearScriptLinks(BPy_Scene *self);
//deprecated methods
static PyObject *Scene_currentFrame(BPy_Scene *self, PyObject *args);
@@ -122,55 +124,62 @@ static PyMethodDef BPy_Scene_methods[] = {
{"getName", (PyCFunction)Scene_getName, METH_NOARGS,
"() - Return Scene name"},
{"setName", (PyCFunction)Scene_setName, METH_VARARGS,
- "(str) - Change Scene name"},
+ "(str) - Change Scene name"},
{"copy", (PyCFunction)Scene_copy, METH_VARARGS,
- "(duplicate_objects = 1) - Return a copy of this scene\n"
+ "(duplicate_objects = 1) - Return a copy of this scene\n"
"The optional argument duplicate_objects defines how the scene\n"
"children are duplicated:\n\t0: Link Objects\n\t1: Link Object Data"
"\n\t2: Full copy\n"},
{"makeCurrent", (PyCFunction)Scene_makeCurrent, METH_NOARGS,
- "() - Make self the current scene"},
+ "() - Make self the current scene"},
{"update", (PyCFunction)Scene_update, METH_VARARGS,
- "(full = 0) - Update scene self.\n"
- "full = 0: sort the base list of objects."
- "full = 1: full update -- also regroups, does ipos, ikas, keys"},
+ "(full = 0) - Update scene self.\n"
+ "full = 0: sort the base list of objects."
+ "full = 1: full update -- also regroups, does ipos, ikas, keys"},
{"link", (PyCFunction)Scene_link, METH_VARARGS,
- "(obj) - Link Object obj to this scene"},
+ "(obj) - Link Object obj to this scene"},
{"unlink", (PyCFunction)Scene_unlink, METH_VARARGS,
- "(obj) - Unlink Object obj from this scene"},
+ "(obj) - Unlink Object obj from this scene"},
{"getChildren", (PyCFunction)Scene_getChildren, METH_NOARGS,
- "() - Return list of all objects linked to scene self"},
+ "() - 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"
+ "() - 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."},
+ {"addScriptLink", (PyCFunction)Scene_addScriptLink, METH_VARARGS,
+ "(text, evt) - Add a new scene scriptlink.\n"
+ "(text) - string: an existing Blender Text name;\n"
+ "(evt) string: FrameChanged, OnLoad or Redraw."},
+ {"clearScriptLinks", (PyCFunction)Scene_clearScriptLinks, METH_NOARGS,
+ "() - Delete all scriptlinks from this scene."},
{"setCurrentCamera", (PyCFunction)Scene_setCurrentCamera, METH_VARARGS,
- "() - Set the currently active Camera"},
+ "() - Set the currently active Camera"},
//DEPRECATED
{"getWinSize", (PyCFunction)Scene_getWinSize, METH_NOARGS,
"() - Return Render window [x,y] dimensions"},
{"setWinSize", (PyCFunction)Scene_setWinSize, METH_VARARGS,
- "(str) - Change Render window [x,y] dimensions"},
+ "(str) - Change Render window [x,y] dimensions"},
{"startFrame", (PyCFunction)Scene_startFrame, METH_VARARGS,
- "(frame) - If frame is given, the start frame is set and"
- "\nreturned in any case"},
+ "(frame) - If frame is given, the start frame is set and"
+ "\nreturned in any case"},
{"endFrame", (PyCFunction)Scene_endFrame, METH_VARARGS,
- "(frame) - If frame is given, the end frame is set and"
- "\nreturned in any case"},
+ "(frame) - If frame is given, the end frame is set and"
+ "\nreturned in any case"},
{"frameSettings", (PyCFunction)Scene_frameSettings, METH_VARARGS,
- "(start, end, current) - Sets or retrieves the Scene's frame"
- " settings.\nIf the frame arguments are specified, they are set. "
- "A tuple (start, end, current) is returned in any case."},
+ "(start, end, current) - Sets or retrieves the Scene's frame"
+ " settings.\nIf the frame arguments are specified, they are set. "
+ "A tuple (start, end, current) is returned in any case."},
{"getRenderdir", (PyCFunction)Scene_getRenderdir, METH_NOARGS,
- "() - Return directory where rendered images are saved to"},
+ "() - Return directory where rendered images are saved to"},
{"getBackbufdir", (PyCFunction)Scene_getBackbufdir, METH_NOARGS,
- "() - Return location of the backbuffer image"},
+ "() - Return location of the backbuffer image"},
{"getRenderingContext", (PyCFunction)Scene_getRenderingContext, METH_NOARGS,
- "() - Get the rendering context for the scene and return it as a BPy_RenderData"},
+ "() - Get the rendering context for the scene and return it as a BPy_RenderData"},
{"currentFrame", (PyCFunction)Scene_currentFrame, METH_VARARGS,
- "(frame) - If frame is given, the current frame is set and"
- "\nreturned in any case"},
+ "(frame) - If frame is given, the current frame is set and"
+ "\nreturned in any case"},
{NULL, NULL, 0, NULL}
};
//-----------------------BPy_Scene method def-------------------------------------------------------------------------
@@ -726,57 +735,60 @@ static PyObject *Scene_getRenderingContext (BPy_Scene *self)
{
if (!self->scene)
return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "Blender Scene was deleted!");
+ "Blender Scene was deleted!");
return RenderData_CreatePyObject(self->scene);
}
-/* Scene.getScriptlinks */
-static PyObject *Scene_getScriptlinks (BPy_Scene *self, PyObject *args)
+/* scene.addScriptLink */
+static PyObject *Scene_addScriptLink (BPy_Scene *self, PyObject *args)
{
Scene *scene = self->scene;
- char *eventname = NULL;
- int event = 0;
- ScriptLink *slink = &(scene)->scriptlink;
+ ScriptLink *slink = NULL;
if (!scene)
return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "Blender Scene was deleted!");
+ "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");
+ slink = &(scene)->scriptlink;
- /* 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 (!EXPP_addScriptLink(slink, args, 1))
+ return EXPP_incr_ret (Py_None);
+ else return NULL;
+}
- if (!list)
- return EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create PyList!");
+/* scene.clearScriptLinks */
+static PyObject *Scene_clearScriptLinks (BPy_Scene *self)
+{
+ Scene *scene = self->scene;
+ ScriptLink *slink = NULL;
- 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));
- }
+ if (!scene)
+ return EXPP_ReturnPyObjError (PyExc_RuntimeError,
+ "Blender Scene was deleted!");
- return list;
- }
+ slink = &(scene)->scriptlink;
+
+ return EXPP_incr_ret(Py_BuildValue("i", EXPP_clearScriptLinks (slink)));
+}
+
+/* scene.getScriptLinks */
+static PyObject *Scene_getScriptLinks (BPy_Scene *self, PyObject *args)
+{
+ Scene *scene = self->scene;
+ ScriptLink *slink = NULL;
+ PyObject *ret = NULL;
+
+ if (!scene)
+ return EXPP_ReturnPyObjError (PyExc_RuntimeError,
+ "Blender Scene was deleted!");
+
+ slink = &(scene)->scriptlink;
+
+ ret = EXPP_getScriptLinks(slink, args, 1);
+
+ if (ret) return ret;
+ else return NULL;
}
/*****************************************************************************/
@@ -786,47 +798,47 @@ static PyObject *Scene_getScriptlinks (BPy_Scene *self, PyObject *args)
static PyObject *Scene_getRenderdir (BPy_Scene *self)
{
return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "Depricated:use RenderData.getRenderPath()");
+ "Deprecated:use RenderData.getRenderPath()");
}
//-----------------------Scene.getBackbufdir ()----------------------------------------------------------------------
static PyObject *Scene_getBackbufdir (BPy_Scene *self)
{
return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "Depricated:use RenderData.getBackbufPath()");
+ "Deprecated:use RenderData.getBackbufPath()");
}
//-----------------------Scene.startFrame ()----------------------------------------------------------------------
static PyObject *Scene_startFrame (BPy_Scene *self, PyObject *args)
{
return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "Depricated:use RenderData.startFrame()");
+ "Deprecated:use RenderData.startFrame()");
}
//-----------------------Scene.endFrame ()----------------------------------------------------------------------
static PyObject *Scene_endFrame (BPy_Scene *self, PyObject *args)
{
return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "Depricated:use RenderData.endFrame()");
+ "Deprecated:use RenderData.endFrame()");
}
//-----------------------Scene.getWinSize ()----------------------------------------------------------------------
static PyObject *Scene_getWinSize(BPy_Scene *self)
{
return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "Depricated:use RenderData.imageSizeX() and RenderData.imageSizeY");
+ "Deprecated:use RenderData.imageSizeX() and RenderData.imageSizeY");
}
//-----------------------Scene.setWinSize()----------------------------------------------------------------------
static PyObject *Scene_setWinSize(BPy_Scene *self, PyObject *args)
{
return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "Depricated:use RenderData.imageSizeX() and RenderData.imageSizeY");
+ "Deprecated:use RenderData.imageSizeX() and RenderData.imageSizeY");
}
//-----------------------Scene.frameSettings()----------------------------------------------------------------------
static PyObject *Scene_frameSettings (BPy_Scene *self, PyObject *args)
{
return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "Depricated:use RenderData.startFrame(), RenderData.endFrame, RenderData.currentFrame");
+ "Deprecated:use RenderData.startFrame(), RenderData.endFrame, RenderData.currentFrame");
}
//-----------------------Scene.currentFrame()-----------------------------------------------------------------------------------------
static PyObject *Scene_currentFrame (BPy_Scene *self, PyObject *args)
{
return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "Depricated:use RenderData.currentFrame");
+ "Deprecated:use RenderData.currentFrame");
}
diff --git a/source/blender/python/api2_2x/doc/Blender.py b/source/blender/python/api2_2x/doc/Blender.py
index 6ab831f9336..b595bfb9e49 100644
--- a/source/blender/python/api2_2x/doc/Blender.py
+++ b/source/blender/python/api2_2x/doc/Blender.py
@@ -62,8 +62,8 @@ The Blender Python API Reference
open-source language.
@author: The Blender Python Team
-@requires: Blender 2.33+ or newer.
-@version: 2.33a-cvs
+@requires: Blender 2.34 or newer.
+@version: 2.34
@see: U{www.blender.org<http://www.blender.org>}
@see: U{projects.blender.org<http://projects.blender.org>}
@see: U{www.python.org<http://www.python.org>}
@@ -115,6 +115,20 @@ def Load (filename = None):
the temporary dir used by Blender before loading the new file.
"""
+def Save (filename, overwrite = 0):
+ """
+ Save a Blender .blend file with the current program data.
+ @type filename: string
+ @param filename: the pathname for the desired .blend file. If it doesn't
+ contain ".blend", this extension is automatically appended.
+ @type overwrite: int (bool)
+ @param overwrite: if non-zero, file 'filename' will be overwritten if it
+ already exists. By default existing files are not overwritten (an error
+ is returned).
+
+ @note: the substring ".B.blend" is not accepted inside 'filename'.
+ """
+
def Quit ():
"""
Exit from Blender immediately.
diff --git a/source/blender/python/api2_2x/doc/Library.py b/source/blender/python/api2_2x/doc/Library.py
index a5757b0dbef..f12b2e8a08b 100644
--- a/source/blender/python/api2_2x/doc/Library.py
+++ b/source/blender/python/api2_2x/doc/Library.py
@@ -48,7 +48,7 @@ def Open (filename):
@type filename: string
@param filename: The filename of a Blender file.
@rtype: bool
- @return: 1 if succesful, 0 otherwise.
+ @return: 1 if successful, 0 otherwise.
"""
def Close ():
diff --git a/source/blender/python/api2_2x/doc/Material.py b/source/blender/python/api2_2x/doc/Material.py
index 9212936926b..5556eb25cd7 100644
--- a/source/blender/python/api2_2x/doc/Material.py
+++ b/source/blender/python/api2_2x/doc/Material.py
@@ -3,6 +3,8 @@
"""
The Blender.Material submodule.
+B{New}: scriptLink methods: L{Material.getScriptLinks}, ...
+
Material
========
@@ -496,5 +498,32 @@ class Material:
"""
Get this Material's Texture list.
@rtype: list of MTex
- @return: a list of Blender MTex objects. None is returned for each empty texture slot.
+ @return: a list of Blender MTex objects. None is returned for each empty
+ texture slot.
+ """
+
+ def getScriptLinks (event):
+ """
+ Get a list with this Material's script links of type 'event'.
+ @type event: string
+ @param event: "FrameChanged" or "Redraw".
+ @rtype: list
+ @return: a list with Blender L{Text} names (the script links of the given
+ 'event' type) or None if there are no script links at all.
+ """
+
+ def clearScriptLinks ():
+ """
+ Delete all this Material's script links.
+ @rtype: bool
+ @return: 0 if some internal problem occurred or 1 if successful.
+ """
+
+ def addScriptLink (text, event):
+ """
+ Add a new script link to this Material.
+ @type text: string
+ @param text: the name of an existing Blender L{Text}.
+ @type event: string
+ @param event: "FrameChanged" or "Redraw".
"""
diff --git a/source/blender/python/api2_2x/doc/NMesh.py b/source/blender/python/api2_2x/doc/NMesh.py
index d7a087a30e4..a1f9e9434bb 100644
--- a/source/blender/python/api2_2x/doc/NMesh.py
+++ b/source/blender/python/api2_2x/doc/NMesh.py
@@ -349,7 +349,7 @@ class NMesh:
"""
Remove all mesh keys stored in this mesh.
@rtype: bool
- @return: True if succesful or False if this NMesh wasn't linked to a real
+ @return: True if successful or False if this NMesh wasn't linked to a real
Blender Mesh yet (or was, but the Mesh had no keys).
@warn: Currently the mesh keys from meshs that are grabbed with
NMesh.GetRaw() or .GetRawFromObject() are preserved, so if you want to
diff --git a/source/blender/python/api2_2x/doc/Render.py b/source/blender/python/api2_2x/doc/Render.py
index 6618b70b988..d12629fc723 100644
--- a/source/blender/python/api2_2x/doc/Render.py
+++ b/source/blender/python/api2_2x/doc/Render.py
@@ -87,38 +87,7 @@ class RenderData:
=====================
This object gives access to Scene rendering contexts in Blender.
"""
-
- def getRenderdir():
- """
- @warn: B{Depricated}: use RenderData.getRenderPath()
- """
-
- def getBackbufdir():
- """
- @warn: B{Depricated}: use RenderData.getBackbufPath()
- """
-
- def getChildren():
- """
- Get all objects linked to this Scene.
- @rtype: list of Blender Objects
- @return: A list with all Blender Objects linked to this Scene.
- """
-
- def getCurrentCamera():
- """
- Get the currently active Camera for this Scene.
- @rtype: Blender Camera
- @return: The currently active Camera.
- """
-
- def setCurrentCamera(camera):
- """
- Set the currently active Camera in this Scene.
- @type camera: Blender Camera
- @param camera: The new active Camera.
- """
-
+
def render():
"""
Render the scene.
diff --git a/source/blender/python/api2_2x/doc/Scene.py b/source/blender/python/api2_2x/doc/Scene.py
index f2ae61270d7..232ce33d567 100644
--- a/source/blender/python/api2_2x/doc/Scene.py
+++ b/source/blender/python/api2_2x/doc/Scene.py
@@ -3,6 +3,8 @@
"""
The Blender.Scene submodule.
+B{New}: scriptLink methods: L{Scene.getScriptLinks}, ...
+
Scene
=====
@@ -91,12 +93,12 @@ class Scene:
def getWinSize():
"""
- @warn: B{Depricated}: use RenderData.imageSizeX() and RenderData.imageSizeY()
+ @warn: B{Deprecated}: use RenderData.imageSizeX() and RenderData.imageSizeY()
"""
def setWinSize(dimensions):
"""
- @warn: B{Depricated}: use RenderData.imageSizeX() and RenderData.imageSizeY
+ @warn: B{Deprecated}: use RenderData.imageSizeX() and RenderData.imageSizeY
"""
def copy(duplicate_objects = 1):
@@ -113,22 +115,22 @@ class Scene:
def startFrame(frame = None):
"""
- @warn: B{Depricated}: use RenderData.startFrame()
+ @warn: B{Deprecated}: use RenderData.startFrame()
"""
def endFrame(frame = None):
"""
- @warn: B{Depricated}: use RenderData.endFrame()
+ @warn: B{Deprecated}: use RenderData.endFrame()
"""
def currentFrame(frame = None):
"""
- @warn: B{Depricated}: use RenderData.currentFrame
+ @warn: B{Deprecated}: use RenderData.currentFrame
"""
def frameSettings(start = None, end = None, current = None):
"""
- @warn: B{Depricated}: use RenderData.startFrame(), RenderData.endFrame, RenderData.currentFrame
+ @warn: B{Deprecated}: use RenderData.startFrame(), RenderData.endFrame, RenderData.currentFrame
"""
def makeCurrent():
@@ -147,6 +149,37 @@ class Scene:
The "full" update is a recent addition to this method.
"""
+ def getRenderdir():
+ """
+ @warn: B{Deprecated}: use RenderData.getRenderPath()
+ """
+
+ def getBackbufdir():
+ """
+ @warn: B{Deprecated}: use RenderData.getBackbufPath()
+ """
+
+ def getChildren():
+ """
+ Get all objects linked to this Scene.
+ @rtype: list of Blender Objects
+ @return: A list with all Blender Objects linked to this Scene.
+ """
+
+ def getCurrentCamera():
+ """
+ Get the currently active Camera for this Scene.
+ @rtype: Blender Camera
+ @return: The currently active Camera.
+ """
+
+ def setCurrentCamera(camera):
+ """
+ Set the currently active Camera in this Scene.
+ @type camera: Blender Camera
+ @param camera: The new active Camera.
+ """
+
def link(object):
"""
Link an Object to this Scene.
@@ -160,3 +193,29 @@ class Scene:
@type object: Blender Object
@param object: A Blender Object.
"""
+
+ def getScriptLinks (event):
+ """
+ Get a list with this Scene's script links of type 'event'.
+ @type event: string
+ @param event: "FrameChanged", "OnLoad" or "Redraw".
+ @rtype: list
+ @return: a list with Blender L{Text} names (the script links of the given
+ 'event' type) or None if there are no script links at all.
+ """
+
+ def clearScriptLinks ():
+ """
+ Delete all this Scene's script links.
+ @rtype: bool
+ @return: 0 if some internal problem occurred or 1 if successful.
+ """
+
+ def addScriptLink (text, event):
+ """
+ Add a new script link to this Scene.
+ @type text: string
+ @param text: the name of an existing Blender L{Text}.
+ @type event: string
+ @param event: "FrameChanged", "OnLoad" or "Redraw".
+ """
diff --git a/source/blender/python/api2_2x/gen_utils.c b/source/blender/python/api2_2x/gen_utils.c
index 44aa86f98c3..20a6e92d9d2 100644
--- a/source/blender/python/api2_2x/gen_utils.c
+++ b/source/blender/python/api2_2x/gen_utils.c
@@ -17,7 +17,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
@@ -32,9 +32,12 @@
#include "gen_utils.h"
#include "constant.h"
+#include <DNA_text_types.h>
+#include <MEM_guardedalloc.h>
+
/*****************************************************************************/
-/* Description: This function clamps an int to the given interval */
-/* [min, max]. */
+/* Description: This function clamps an int to the given interval */
+/* [min, max]. */
/*****************************************************************************/
int EXPP_ClampInt (int value, int min, int max)
{
@@ -44,8 +47,8 @@ int EXPP_ClampInt (int value, int min, int max)
}
/*****************************************************************************/
-/* Description: This function clamps a float to the given interval */
-/* [min, max]. */
+/* Description: This function clamps a float to the given interval */
+/* [min, max]. */
/*****************************************************************************/
float EXPP_ClampFloat (float value, float min, float max)
{
@@ -56,7 +59,7 @@ float EXPP_ClampFloat (float value, float min, float max)
/*****************************************************************************/
/* Description: This function returns true if both given strings are equal, */
-/* otherwise it returns false. */
+/* otherwise it returns false. */
/*****************************************************************************/
int StringEqual (const char * string1, const char * string2)
{
@@ -64,8 +67,8 @@ int StringEqual (const char * string1, const char * string2)
}
/*****************************************************************************/
-/* Description: This function returns the name of the given ID struct */
-/* without the Object type identifying characters prepended. */
+/* Description: This function returns the name of the given ID struct */
+/* without the Object type identifying characters prepended. */
/*****************************************************************************/
char * GetIdName (ID *id)
{
@@ -73,8 +76,8 @@ char * GetIdName (ID *id)
}
/*****************************************************************************/
-/* Description: This function returns the ID of the object with given name */
-/* from a given list. */
+/* Description: This function returns the ID of the object with given name */
+/* from a given list. */
/*****************************************************************************/
ID *GetIdFromList(ListBase *list, char *name)
{
@@ -89,8 +92,8 @@ ID *GetIdFromList(ListBase *list, char *name)
}
/*****************************************************************************/
-/* Description: These functions set an internal string with the given type */
-/* and error_msg arguments. */
+/* Description: These functions set an internal string with the given type */
+/* and error_msg arguments. */
/*****************************************************************************/
PyObject *EXPP_ReturnPyObjError (PyObject * type, char * error_msg)
@@ -106,8 +109,8 @@ int EXPP_ReturnIntError (PyObject *type, char *error_msg)
}
/*****************************************************************************/
-/* Description: This function increments the reference count of the given */
-/* Python object (usually Py_None) and returns it. */
+/* Description: This function increments the reference count of the given */
+/* Python object (usually Py_None) and returns it. */
/*****************************************************************************/
PyObject *EXPP_incr_ret (PyObject *object)
@@ -117,7 +120,7 @@ PyObject *EXPP_incr_ret (PyObject *object)
}
/*****************************************************************************/
-/* Description: This function maps the event identifier to a string. */
+/* Description: This function maps the event identifier to a string. */
/*****************************************************************************/
char * event_to_name(short event)
{
@@ -135,8 +138,8 @@ char * event_to_name(short event)
}
/*****************************************************************************/
-/* Description: Checks whether all objects in a PySequence are of a same */
-/* given type. Returns 0 if not, 1 on success. */
+/* Description: Checks whether all objects in a PySequence are of a same */
+/* given type. Returns 0 if not, 1 on success. */
/*****************************************************************************/
int EXPP_check_sequence_consistency(PyObject *seq, PyTypeObject *against)
{
@@ -181,61 +184,180 @@ PyObject *EXPP_tuple_repr(PyObject *self, int size)
/****************************************************************************/
/* Description: searches through a map for a pair with a given name. If the */
-/* pair is present, its ival is stored in *ival and nonzero is */
-/* returned. If the pair is absent, zero is returned. */
+/* pair is present, its ival is stored in *ival and nonzero is */
+/* returned. If the pair is absent, zero is returned. */
/****************************************************************************/
int EXPP_map_getIntVal (const EXPP_map_pair *map, const char *sval, int *ival)
{
- while (map->sval)
- {
- if (StringEqual(sval, map->sval))
- {
- *ival = map->ival;
- return 1;
- }
- ++map;
- }
- return 0;
+ while (map->sval)
+ {
+ if (StringEqual(sval, map->sval))
+ {
+ *ival = map->ival;
+ return 1;
+ }
+ ++map;
+ }
+ return 0;
}
/****************************************************************************/
/* Description: searches through a map for a pair with a given name. If the */
-/* pair is present, its ival is stored in *ival and nonzero is */
-/* returned. If the pair is absent, zero is returned. */
-/* note: this function is identical to EXPP_map_getIntVal except that the */
-/* output is stored in a short value. */
+/* pair is present, its ival is stored in *ival and nonzero is */
+/* returned. If the pair is absent, zero is returned. */
+/* note: this function is identical to EXPP_map_getIntVal except that the */
+/* output is stored in a short value. */
/****************************************************************************/
int EXPP_map_getShortVal (const EXPP_map_pair *map,
- const char *sval, short *ival)
+ const char *sval, short *ival)
{
- while (map->sval)
- {
- if (StringEqual(sval, map->sval))
- {
- *ival = map->ival;
- return 1;
- }
- ++map;
- }
- return 0;
+ while (map->sval)
+ {
+ if (StringEqual(sval, map->sval))
+ {
+ *ival = map->ival;
+ return 1;
+ }
+ ++map;
+ }
+ return 0;
}
/****************************************************************************/
/* Description: searches through a map for a pair with a given ival. If the */
-/* pair is present, a pointer to its name is stored in *sval */
-/* and nonzero is returned. If the pair is absent, zero is */
-/* returned. */
+/* pair is present, a pointer to its name is stored in *sval */
+/* and nonzero is returned. If the pair is absent, zero is */
+/* returned. */
/****************************************************************************/
int EXPP_map_getStrVal (const EXPP_map_pair *map, int ival, const char **sval)
{
- while (map->sval)
- {
- if (ival == map->ival)
- {
- *sval = map->sval;
- return 1;
- }
- ++map;
- }
- return 0;
+ while (map->sval)
+ {
+ if (ival == map->ival)
+ {
+ *sval = map->sval;
+ return 1;
+ }
+ ++map;
+ }
+ return 0;
+}
+
+/************************************************************************/
+/* Scriptlink-related functions, used by scene, object, etc. bpyobjects */
+/************************************************************************/
+PyObject *EXPP_getScriptLinks (ScriptLink *slink, PyObject *args, int is_scene)
+{
+ PyObject *list = NULL;
+ char *eventname = NULL;
+ int i, event = 0;
+
+ /* actually !scriptlink shouldn't happen ... */
+ if (!slink || !slink->totscript)
+ return EXPP_incr_ret (Py_None);
+
+ if (!PyArg_ParseTuple(args, "s", &eventname))
+ return EXPP_ReturnPyObjError (PyExc_TypeError,
+ "expected event name (string) as argument");
+
+ list = PyList_New(0);
+ if (!list)
+ return EXPP_ReturnPyObjError (PyExc_MemoryError,
+ "couldn't create PyList!");
+
+ if (!strcmp(eventname, "FrameChanged"))
+ event = SCRIPT_FRAMECHANGED;
+ else if (!strcmp(eventname, "Redraw"))
+ event = SCRIPT_REDRAW;
+ else if (is_scene && !strcmp(eventname, "OnLoad"))
+ event = SCRIPT_ONLOAD;
+ else
+ return EXPP_ReturnPyObjError (PyExc_AttributeError,
+ "invalid event name.");
+
+ 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;
+}
+
+int EXPP_clearScriptLinks (ScriptLink *slink)
+{
+ /* actually !scriptlink shouldn't happen ... */
+ if (!slink || !slink->totscript) return -1;
+
+ if (slink->scripts) MEM_freeN(slink->scripts);
+ if (slink->flag) MEM_freeN(slink->flag);
+
+ slink->scripts = NULL;
+ slink->flag = NULL;
+ slink->totscript = slink->actscript = 0;
+
+ return 0; /* normal return */
+}
+
+int EXPP_addScriptLink (ScriptLink *slink, PyObject *args, int is_scene)
+{
+ int event = 0, found_txt = 0;
+ void *stmp = NULL, *ftmp = NULL;
+ Text *bltxt = G.main->text.first;
+ char *textname = NULL;
+ char *eventname = NULL;
+
+ /* !scriptlink shouldn't happen ... */
+ if (!slink) {
+ return EXPP_ReturnIntError (PyExc_RuntimeError,
+ "internal error: no scriptlink!");
+ }
+
+ if (!PyArg_ParseTuple(args, "ss", &textname, &eventname))
+ return EXPP_ReturnIntError (PyExc_TypeError,
+ "expected two strings as arguments");
+
+ while (bltxt) {
+ if (!strcmp(bltxt->id.name+2, textname)) {
+ found_txt = 1;
+ break;
+ }
+ bltxt = bltxt->id.next;
+ }
+
+ if (!found_txt)
+ return EXPP_ReturnIntError (PyExc_AttributeError,
+ "no such Blender Text.");
+
+ if (!strcmp(eventname, "FrameChanged"))
+ event = SCRIPT_FRAMECHANGED;
+ else if (!strcmp(eventname, "Redraw"))
+ event = SCRIPT_REDRAW;
+ else if (is_scene && !strcmp(eventname, "OnLoad"))
+ event = SCRIPT_ONLOAD;
+ else
+ return EXPP_ReturnIntError (PyExc_AttributeError,
+ "invalid event name.");
+
+ stmp= slink->scripts;
+ slink->scripts= MEM_mallocN(sizeof(ID*)*(slink->totscript+1), "bpySlinkL");
+
+ ftmp= slink->flag;
+ slink->flag= MEM_mallocN(sizeof(short*)*(slink->totscript+1), "bpySlinkF");
+
+ if (slink->totscript) {
+ memcpy(slink->scripts, stmp, sizeof(ID*)*(slink->totscript));
+ MEM_freeN(stmp);
+
+ memcpy(slink->flag, ftmp, sizeof(short)*(slink->totscript));
+ MEM_freeN(ftmp);
+ }
+
+ slink->scripts[slink->totscript] = (ID*)bltxt;
+ slink->flag[slink->totscript]= event;
+
+ slink->totscript++;
+
+ if (slink->actscript < 1) slink->actscript = 1;
+
+ return 0; /* normal exit */
}
diff --git a/source/blender/python/api2_2x/gen_utils.h b/source/blender/python/api2_2x/gen_utils.h
index efeb0a43370..cb17d4bb05e 100644
--- a/source/blender/python/api2_2x/gen_utils.h
+++ b/source/blender/python/api2_2x/gen_utils.h
@@ -17,7 +17,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
@@ -60,7 +60,7 @@ PyObject *PythonIncRef (PyObject *object);
char * event_to_name (short event);
float EXPP_ClampFloat (float value, float min, float max);
-int EXPP_ClampInt (int value, int min, int max);
+int EXPP_ClampInt (int value, int min, int max);
PyObject *EXPP_incr_ret (PyObject *object);
PyObject *EXPP_ReturnPyObjError (PyObject * type, char * error_msg);
@@ -71,16 +71,21 @@ PyObject *EXPP_tuple_repr(PyObject *self, int size);
/* mapping utilities - see Texture.c for an example of how to use these */
typedef struct {
- const char *sval;
- int ival;
+ const char *sval;
+ int ival;
} EXPP_map_pair;
/* maps must end with a pair that has NULL as sval */
int EXPP_map_getIntVal (const EXPP_map_pair *map,
- const char *sval, int *ival);
+ const char *sval, int *ival);
int EXPP_map_getShortVal (const EXPP_map_pair *map,
- const char *sval, short *ival);
+ const char *sval, short *ival);
int EXPP_map_getStrVal (const EXPP_map_pair *map,
- int ival, const char **sval);
+ int ival, const char **sval);
+
+/* scriplinks-related: */
+PyObject *EXPP_getScriptLinks (ScriptLink *slink, PyObject *args, int is_scene);
+int EXPP_clearScriptLinks (ScriptLink *slink);
+int EXPP_addScriptLink (ScriptLink *slink, PyObject *args, int is_scene);
#endif /* EXPP_gen_utils_h */