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-03-31 08:18:39 +0400
committerWillian Padovani Germano <wpgermano@gmail.com>2004-03-31 08:18:39 +0400
commitfa0196b8f920c6662cf7bc1d74161febb36787cb (patch)
tree73d9b4be486aaccd67aafc7c73f9be1be52ffedd /source/blender/python/api2_2x
parent2b27a909f022ba568a7404d5283f70f8a569ff0e (diff)
BPython:
- tentative fix for scripts with CR/LF endings and split lines: in 2.32, the ac3d and vrml2 exporters, for example, had lines split with '\\\\' and so gave syntax errors when executed on Win platforms, because the scripts bundled with Win binaries had dos line endings. - Chris Keith has written code to execute Python scripts from the command-line, with '-P ' switch: "blender -P filename": a Blender.Quit function was also added, so Blender can quit after running the script (end the script with Blender.Quit()), but there's still work to be done in this part, including adding more functions, to load / save .blend files and to run scripts. More testing and discussions are necessary. Thanks Chris, for both your contributions and your patience, since I wasn't available to check / commit this for a while.
Diffstat (limited to 'source/blender/python/api2_2x')
-rw-r--r--source/blender/python/api2_2x/Blender.c32
-rw-r--r--source/blender/python/api2_2x/Blender.h15
-rw-r--r--source/blender/python/api2_2x/Draw.c5
3 files changed, 23 insertions, 29 deletions
diff --git a/source/blender/python/api2_2x/Blender.c b/source/blender/python/api2_2x/Blender.c
index 3f83185fc79..29c6e4fbdd1 100644
--- a/source/blender/python/api2_2x/Blender.c
+++ b/source/blender/python/api2_2x/Blender.c
@@ -29,6 +29,9 @@
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
+//#include "BKE_utildefines.h"
+#include "BIF_usiblender.h"
+
#include "Blender.h"
/*****************************************************************************/
@@ -157,7 +160,6 @@ PyObject *Blender_Get (PyObject *self, PyObject *args)
/*****************************************************************************/
PyObject *Blender_Redraw(PyObject *self, PyObject *args)
{
-
int wintype = SPACE_VIEW3D;
if (!PyArg_ParseTuple (args, "|i", &wintype))
@@ -172,24 +174,24 @@ PyObject *Blender_Redraw(PyObject *self, PyObject *args)
/*****************************************************************************/
/* Function: Blender_ReleaseGlobalDict */
/* Python equivalent: Blender.ReleaseGlobalDict */
-/* Description: Receives an int (treated as boolean) to define */
-/* whether the global Python dictionary should be */
-/* cleared after the script is run or not. Default */
-/* is to clear (to release). To change this, call */
-/* Blender.ReleaseGlobalDict with a non-zero int */
-/* argument. If called with an empty arg list, it */
-/* doesn't change anything. */
-/* Returns the current behavior. */
+/* Description: Deprecated function. */
/*****************************************************************************/
PyObject *Blender_ReleaseGlobalDict(PyObject *self, PyObject *args)
{
- if (!PyArg_ParseTuple (args, "|i", &EXPP_releaseGlobalDict))
- {
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected int argument (or nothing)");
- }
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+/*****************************************************************************/
+/* Function: Blender_Quit */
+/* Python equivalent: Blender.Quit */
+/*****************************************************************************/
+PyObject *Blender_Quit(PyObject *self)
+{
+ exit_usiblender();
- return Py_BuildValue("i", (EXPP_releaseGlobalDict?1:0));
+ Py_INCREF(Py_None);
+ return Py_None;
}
/*****************************************************************************/
diff --git a/source/blender/python/api2_2x/Blender.h b/source/blender/python/api2_2x/Blender.h
index ff72d3bbd36..f44df3e3cb0 100644
--- a/source/blender/python/api2_2x/Blender.h
+++ b/source/blender/python/api2_2x/Blender.h
@@ -50,11 +50,6 @@
/* From Window.h, used here by Blender_Redraw */
PyObject *M_Window_Redraw(PyObject *self, PyObject *args);
-/* This global variable controls whether the global Interpreter dictionary
- * should be cleared after a script is run. Default is to clear it.
- * See Blender.ReleaseGlobalDict(bool) */
-extern short EXPP_releaseGlobalDict;
-
/*****************************************************************************/
/* Python API function prototypes for the Blender module. */
/*****************************************************************************/
@@ -62,6 +57,7 @@ PyObject *Blender_Set (PyObject *self, PyObject *args);
PyObject *Blender_Get (PyObject *self, PyObject *args);
PyObject *Blender_Redraw(PyObject *self, PyObject *args);
PyObject *Blender_ReleaseGlobalDict(PyObject *self, PyObject *args);
+PyObject *Blender_Quit(PyObject *self);
/*****************************************************************************/
/* The following string definitions are used for documentation strings. */
@@ -88,10 +84,10 @@ char Blender_Get_doc[] =
char Blender_Redraw_doc[] = "() - Redraw all 3D windows";
char Blender_ReleaseGlobalDict_doc[] =
-"(int) - Define whether the global Python Interpreter dictionary\n\
- should be cleared after the script is run. Default is\n\
- to clear (non-zero int).\n\
-() - Return the current behavior as a bool value (0 is false, 1 is true)\n";
+"Deprecated, please use the Blender.Registry module solution instead.";
+
+char Blender_Quit_doc[] =
+"() - Quit Blender. Experimental, please use with caution.";
/*****************************************************************************/
/* Python method structure definition. */
@@ -100,6 +96,7 @@ struct PyMethodDef Blender_methods[] = {
{"Set", &Blender_Set, METH_VARARGS, Blender_Set_doc},
{"Get", &Blender_Get, METH_VARARGS, Blender_Get_doc},
{"Redraw", &Blender_Redraw, METH_VARARGS, Blender_Redraw_doc},
+ {"Quit", &Blender_Quit, METH_NOARGS, Blender_Quit_doc},
{"ReleaseGlobalDict", &Blender_ReleaseGlobalDict,
METH_VARARGS, Blender_ReleaseGlobalDict_doc},
{NULL, NULL}
diff --git a/source/blender/python/api2_2x/Draw.c b/source/blender/python/api2_2x/Draw.c
index 5ad4387b483..bd1494dbe51 100644
--- a/source/blender/python/api2_2x/Draw.c
+++ b/source/blender/python/api2_2x/Draw.c
@@ -68,11 +68,6 @@
#include "interface.h"
#include "mydevice.h" /*@ for all the event constants */
-
-/* declared in ../BPY_extern.h,
- * used to control global dictionary persistence: */
-extern short EXPP_releaseGlobalDict;
-
/* This one was an extern in BPY_main.h, but only opy_draw.c was using it */
int g_window_redrawn;