Merged changes in the trunk up to revision 29994.

This commit is contained in:
2010-07-05 18:37:29 +00:00
231 changed files with 4927 additions and 2026 deletions

View File

@@ -0,0 +1,28 @@
import bpy
# print all objects
for obj in bpy.data.objects:
print(obj.name)
# print all scene names in a list
print(bpy.data.scenes.keys())
# remove mesh Cube
if "Cube" in bpy.data.meshes:
mesh = bpy.data.meshes["Cube"]
print("removing mesh", mesh)
bpy.data.meshes.unlink(mesh)
# write images into a file next to the blend
file = open(bpy.data.filepath.replace(".blend", ".txt"), 'w')
for image in bpy.data.images:
file.write("%s %dx%d\n" % (image.filepath, image.size[0], image.size[1]))
file.close()

View File

@@ -179,7 +179,11 @@ def pyprop2sphinx(ident, fw, identifier, py_prop):
'''
python property to sphinx
'''
fw(ident + ".. attribute:: %s\n\n" % identifier)
# readonly properties use "data" directive, variables use "attribute" directive
if py_prop.fset is None:
fw(ident + ".. data:: %s\n\n" % identifier)
else:
fw(ident + ".. attribute:: %s\n\n" % identifier)
write_indented_lines(ident + " ", fw, py_prop.__doc__)
if py_prop.fset is None:
fw(ident + " (readonly)\n\n")
@@ -303,7 +307,7 @@ def rna2sphinx(BASEPATH):
if bpy.app.build_revision != "Unknown":
version_string = version_string + " r" + bpy.app.build_revision
fw("project = 'Blender 3D'\n")
fw("project = 'Blender'\n")
# fw("master_doc = 'index'\n")
fw("copyright = u'Blender Foundation'\n")
fw("version = '%s - UNSTABLE API'\n" % version_string)
@@ -330,7 +334,7 @@ def rna2sphinx(BASEPATH):
fw("\n")
fw("This document is an API reference for Blender %s. built %s.\n" % (version_string, bpy.app.build_date))
fw("\n")
fw("An introduction to blender and python can be found at <http://wiki.blender.org/index.php/Dev:2.5/Py/API/Intro>\n")
fw("An introduction to Blender and Python can be found at <http://wiki.blender.org/index.php/Dev:2.5/Py/API/Intro>\n")
fw("\n")
fw("`A PDF version of this document is also available <blender_python_reference_250.pdf>`__\n")
fw("\n")
@@ -357,6 +361,7 @@ def rna2sphinx(BASEPATH):
fw("\n")
fw(".. toctree::\n")
fw(" :maxdepth: 1\n\n")
fw(" bpy.data.rst\n\n") # note: not actually a module
fw(" bpy.ops.rst\n\n")
fw(" bpy.types.rst\n\n")
@@ -398,8 +403,8 @@ def rna2sphinx(BASEPATH):
filepath = os.path.join(BASEPATH, "bpy.ops.rst")
file = open(filepath, "w")
fw = file.write
fw("Blender Operators (bpy.ops)\n")
fw("===========================\n\n")
fw("Operators (bpy.ops)\n")
fw("===================\n\n")
fw(".. toctree::\n")
fw(" :glob:\n\n")
fw(" bpy.ops.*\n\n")
@@ -408,14 +413,37 @@ def rna2sphinx(BASEPATH):
filepath = os.path.join(BASEPATH, "bpy.types.rst")
file = open(filepath, "w")
fw = file.write
fw("Blender Types (bpy.types)\n")
fw("=========================\n\n")
fw("Types (bpy.types)\n")
fw("=================\n\n")
fw(".. toctree::\n")
fw(" :glob:\n\n")
fw(" bpy.types.*\n\n")
file.close()
# not actually a module, only write this file so we
# can reference in the TOC
filepath = os.path.join(BASEPATH, "bpy.data.rst")
file = open(filepath, "w")
fw = file.write
fw("Data Access (bpy.data)\n")
fw("======================\n\n")
fw(".. module:: bpy\n")
fw("\n")
fw("This module is used for all blender/python access.\n")
fw("\n")
fw(".. literalinclude:: ../examples/bpy.data.py\n")
fw("\n")
fw(".. data:: data\n")
fw("\n")
fw(" Access to blenders internal data\n")
fw("\n")
fw(" :type: :class:`bpy.types.Main`\n")
file.close()
EXAMPLE_SET_USED.add("bpy.data")
# python modules
from bpy import utils as module
pymodule2sphinx(BASEPATH, "bpy.utils", module, "Utilities (bpy.utils)")
@@ -436,7 +464,7 @@ def rna2sphinx(BASEPATH):
del module
import blf as module
pymodule2sphinx(BASEPATH, "blf", module, "Blender Font Drawing (blf)")
pymodule2sphinx(BASEPATH, "blf", module, "Font Drawing (blf)")
del module
# game engine
@@ -535,12 +563,21 @@ def rna2sphinx(BASEPATH):
fw(".. class:: %s\n\n" % struct.identifier)
fw(" %s\n\n" % struct.description)
for prop in struct.properties:
fw(" .. attribute:: %s\n\n" % prop.identifier)
# properties sorted in alphabetical order
zip_props_ids = zip(struct.properties, [prop.identifier for prop in struct.properties])
zip_props_ids = sorted(zip_props_ids, key=lambda p: p[1])
sorted_struct_properties = [x[0] for x in zip_props_ids]
for prop in sorted_struct_properties:
type_descr = prop.get_type_description(class_fmt=":class:`%s`")
# readonly properties use "data" directive, variables properties use "attribute" directive
if 'readonly' in type_descr:
fw(" .. data:: %s\n\n" % prop.identifier)
else:
fw(" .. attribute:: %s\n\n" % prop.identifier)
if prop.description:
fw(" %s\n\n" % prop.description)
type_descr = prop.get_type_description(class_fmt=":class:`%s`")
fw(" :type: %s\n\n" % type_descr)
# python attributes

View File

@@ -8,7 +8,7 @@ SSH_HOST="ideasman42@emo.blender.org"
SSH_UPLOAD="/data/www/vhosts/www.blender.org/documentation/250PythonDoc"
# dont delete existing docs, now partial updates are used for quick builds.
$BLENDER -b -P ./source/blender/python/doc/sphinx_doc_gen.py
$BLENDER --background --python ./source/blender/python/doc/sphinx_doc_gen.py
# html
sphinx-build source/blender/python/doc/sphinx-in source/blender/python/doc/sphinx-out

View File

@@ -322,20 +322,20 @@ static int Buffer_ass_item(PyObject *self, int i, PyObject *v)
}
if (buf->type==GL_BYTE) {
if (!PyArg_Parse(v, "b;Coordinates must be ints", &buf->buf.asbyte[i]))
if (!PyArg_Parse(v, "b:Coordinates must be ints", &buf->buf.asbyte[i]))
return -1;
} else if (buf->type==GL_SHORT) {
if (!PyArg_Parse(v, "h;Coordinates must be ints", &buf->buf.asshort[i]))
if (!PyArg_Parse(v, "h:Coordinates must be ints", &buf->buf.asshort[i]))
return -1;
} else if (buf->type==GL_INT) {
if (!PyArg_Parse(v, "i;Coordinates must be ints", &buf->buf.asint[i]))
if (!PyArg_Parse(v, "i:Coordinates must be ints", &buf->buf.asint[i]))
return -1;
} else if (buf->type==GL_FLOAT) {
if (!PyArg_Parse(v, "f;Coordinates must be floats", &buf->buf.asfloat[i]))
if (!PyArg_Parse(v, "f:Coordinates must be floats", &buf->buf.asfloat[i]))
return -1;
} else if (buf->type==GL_DOUBLE) {
if (!PyArg_Parse(v, "d;Coordinates must be floats", &buf->buf.asdouble[i]))
if (!PyArg_Parse(v, "d:Coordinates must be floats", &buf->buf.asdouble[i]))
return -1;
}
return 0;

View File

@@ -46,7 +46,7 @@ static PyObject *py_blf_position(PyObject *self, PyObject *args)
int fontid;
float x, y, z;
if (!PyArg_ParseTuple(args, "ifff:BLF.position", &fontid, &x, &y, &z))
if (!PyArg_ParseTuple(args, "ifff:blf.position", &fontid, &x, &y, &z))
return NULL;
BLF_position(fontid, x, y, z);
@@ -71,7 +71,7 @@ static PyObject *py_blf_size(PyObject *self, PyObject *args)
{
int fontid, size, dpi;
if (!PyArg_ParseTuple(args, "iii:BLF.size", &fontid, &size, &dpi))
if (!PyArg_ParseTuple(args, "iii:blf.size", &fontid, &size, &dpi))
return NULL;
BLF_size(fontid, size, dpi);
@@ -95,7 +95,7 @@ static PyObject *py_blf_aspect(PyObject *self, PyObject *args)
float aspect;
int fontid;
if (!PyArg_ParseTuple(args, "if:BLF.aspect", &fontid, &aspect))
if (!PyArg_ParseTuple(args, "if:blf.aspect", &fontid, &aspect))
return NULL;
BLF_aspect(fontid, aspect);
@@ -118,7 +118,7 @@ static PyObject *py_blf_blur(PyObject *self, PyObject *args)
{
int blur, fontid;
if (!PyArg_ParseTuple(args, "ii:BLF.blur", &fontid, &blur))
if (!PyArg_ParseTuple(args, "ii:blf.blur", &fontid, &blur))
return NULL;
BLF_blur(fontid, blur);
@@ -142,7 +142,7 @@ static PyObject *py_blf_draw(PyObject *self, PyObject *args)
char *text;
int fontid;
if (!PyArg_ParseTuple(args, "is:BLF.draw", &fontid, &text))
if (!PyArg_ParseTuple(args, "is:blf.draw", &fontid, &text))
return NULL;
BLF_draw(fontid, text);
@@ -169,7 +169,7 @@ static PyObject *py_blf_dimensions(PyObject *self, PyObject *args)
PyObject *ret;
int fontid;
if (!PyArg_ParseTuple(args, "is:BLF.dimensions", &fontid, &text))
if (!PyArg_ParseTuple(args, "is:blf.dimensions", &fontid, &text))
return NULL;
BLF_width_and_height(fontid, text, &r_width, &r_height);
@@ -201,7 +201,7 @@ static PyObject *py_blf_clipping(PyObject *self, PyObject *args)
float xmin, ymin, xmax, ymax;
int fontid;
if (!PyArg_ParseTuple(args, "iffff:BLF.clipping", &fontid, &xmin, &ymin, &xmax, &ymax))
if (!PyArg_ParseTuple(args, "iffff:blf.clipping", &fontid, &xmin, &ymin, &xmax, &ymax))
return NULL;
BLF_clipping(fontid, xmin, ymin, xmax, ymax);
@@ -223,7 +223,7 @@ static PyObject *py_blf_disable(PyObject *self, PyObject *args)
{
int option, fontid;
if (!PyArg_ParseTuple(args, "ii:BLF.disable", &fontid, &option))
if (!PyArg_ParseTuple(args, "ii:blf.disable", &fontid, &option))
return NULL;
BLF_disable(fontid, option);
@@ -245,7 +245,7 @@ static PyObject *py_blf_enable(PyObject *self, PyObject *args)
{
int option, fontid;
if (!PyArg_ParseTuple(args, "ii:BLF.enable", &fontid, &option))
if (!PyArg_ParseTuple(args, "ii:blf.enable", &fontid, &option))
return NULL;
BLF_enable(fontid, option);
@@ -268,7 +268,7 @@ static PyObject *py_blf_rotation(PyObject *self, PyObject *args)
float angle;
int fontid;
if (!PyArg_ParseTuple(args, "if:BLF.rotation", &fontid, &angle))
if (!PyArg_ParseTuple(args, "if:blf.rotation", &fontid, &angle))
return NULL;
BLF_rotation(fontid, angle);
@@ -299,7 +299,7 @@ static PyObject *py_blf_shadow(PyObject *self, PyObject *args)
int level, fontid;
float r, g, b, a;
if (!PyArg_ParseTuple(args, "iiffff:BLF.shadow", &fontid, &level, &r, &g, &b, &a))
if (!PyArg_ParseTuple(args, "iiffff:blf.shadow", &fontid, &level, &r, &g, &b, &a))
return NULL;
if (level != 0 && level != 3 && level != 5) {
@@ -328,7 +328,7 @@ static PyObject *py_blf_shadow_offset(PyObject *self, PyObject *args)
{
int x, y, fontid;
if (!PyArg_ParseTuple(args, "iii:BLF.shadow_offset", &fontid, &x, &y))
if (!PyArg_ParseTuple(args, "iii:blf.shadow_offset", &fontid, &x, &y))
return NULL;
BLF_shadow_offset(fontid, x, y);

View File

@@ -237,16 +237,11 @@ static PyObject *blender_import( PyObject * self, PyObject * args, PyObject * k
* our reload() module, to handle reloading in-memory scripts
*/
static PyObject *blender_reload( PyObject * self, PyObject * args )
static PyObject *blender_reload( PyObject * self, PyObject * module )
{
PyObject *exception, *err, *tb;
PyObject *module = NULL;
PyObject *newmodule = NULL;
int found= 0;
/* check for a module arg */
if( !PyArg_ParseTuple( args, "O:bpy_reload_meth", &module ) )
return NULL;
/* try reimporting from file */
newmodule = PyImport_ReloadModule( module );
@@ -280,7 +275,7 @@ static PyObject *blender_reload( PyObject * self, PyObject * args )
}
PyMethodDef bpy_import_meth[] = { {"bpy_import_meth", (PyCFunction)blender_import, METH_VARARGS | METH_KEYWORDS, "blenders import"} };
PyMethodDef bpy_reload_meth[] = { {"bpy_reload_meth", (PyCFunction)blender_reload, METH_VARARGS, "blenders reload"} };
PyMethodDef bpy_reload_meth[] = { {"bpy_reload_meth", (PyCFunction)blender_reload, METH_O, "blenders reload"} };
/* Clear user modules.

View File

@@ -147,7 +147,7 @@ void BPy_init_modules( void )
PyObject *mod;
/* Needs to be first since this dir is needed for future modules */
char *modpath= BLI_gethome_folder("scripts/modules", BLI_GETHOME_ALL);
char *modpath= BLI_get_folder(BLENDER_SCRIPTS, "modules");
if(modpath) {
// printf("bpy: found module path '%s'.\n", modpath);
PyObject *sys_path= PySys_GetObject("path"); /* borrow */

View File

@@ -177,7 +177,7 @@ static PyObject *CreateGlobalDictionary( bContext *C, const char *filename )
/* must be called before Py_Initialize */
void BPY_start_python_path(void)
{
char *py_path_bundle= BLI_gethome_folder("python", BLI_GETHOME_ALL);
char *py_path_bundle= BLI_get_folder(BLENDER_PYTHON, NULL);
if(py_path_bundle==NULL)
return;
@@ -231,6 +231,8 @@ void BPY_start_python( int argc, char **argv )
BPY_start_python_path(); /* allow to use our own included python */
// Py_SetProgramName(); // extern char bprogname[FILE_MAXDIR+FILE_MAXFILE];
Py_Initialize( );
// PySys_SetArgv( argc, argv); // broken in py3, not a huge deal