- 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.
This commit is contained in:
2004-03-31 04:18:39 +00:00
parent 2b27a909f0
commit fa0196b8f9
6 changed files with 98 additions and 44 deletions

View File

@@ -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;
}
return Py_BuildValue("i", (EXPP_releaseGlobalDict?1:0));
/*****************************************************************************/
/* Function: Blender_Quit */
/* Python equivalent: Blender.Quit */
/*****************************************************************************/
PyObject *Blender_Quit(PyObject *self)
{
exit_usiblender();
Py_INCREF(Py_None);
return Py_None;
}
/*****************************************************************************/

View File

@@ -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}

View File

@@ -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;