diff options
author | Campbell Barton <ideasman42@gmail.com> | 2007-03-26 23:44:44 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2007-03-26 23:44:44 +0400 |
commit | 2b8bed8598004683bb20efad6e9bd15243ad2d24 (patch) | |
tree | 740c4ad4f81b7c2ad5a06f89514cf1a044b4a2cc /source/blender/python | |
parent | e968f6ec4bdfdacb1148340c137e2a50ce740139 (diff) |
py api
* stopped bpy from importing automaticaly as decieded in the meeting.
* removed Blender.Main, since we agree it will be called bpy, renamed files also.
* updated epydocs from this and last commit.
* updated scripts to use bpy.*, and bugfix's for widgetwizard
Diffstat (limited to 'source/blender/python')
-rw-r--r-- | source/blender/python/BPY_interface.c | 8 | ||||
-rw-r--r-- | source/blender/python/api2_2x/BPyModule.c (renamed from source/blender/python/api2_2x/Main.c) | 144 | ||||
-rw-r--r-- | source/blender/python/api2_2x/BPyModule.h (renamed from source/blender/python/api2_2x/Main.h) | 15 | ||||
-rw-r--r-- | source/blender/python/api2_2x/Blender.c | 2 | ||||
-rw-r--r-- | source/blender/python/api2_2x/doc/API_intro.py | 2 | ||||
-rw-r--r-- | source/blender/python/api2_2x/doc/Bpy.py | 80 |
6 files changed, 121 insertions, 130 deletions
diff --git a/source/blender/python/BPY_interface.c b/source/blender/python/BPY_interface.c index c8173866f97..a6f150fe1e9 100644 --- a/source/blender/python/BPY_interface.c +++ b/source/blender/python/BPY_interface.c @@ -65,7 +65,7 @@ #include "api2_2x/Camera.h" #include "api2_2x/Draw.h" #include "api2_2x/Registry.h" -#include "api2_2x/Main.h" /* for the "bpy" default module */ +#include "api2_2x/BPyModule.h" /* for the "bpy" default module */ /* for scriptlinks */ #include "DNA_lamp_types.h" @@ -116,6 +116,7 @@ int setup_armature_weakrefs() *support for packages here e.g. import `package.module` */ static struct _inittab BPy_Inittab_Modules[] = { {"Blender", M_Blender_Init}, + {"bpy", M_BPy_Init}, {NULL, NULL} }; @@ -1972,8 +1973,9 @@ void init_ourImport( void ) m = PyImport_AddModule( "__builtin__" ); d = PyModule_GetDict( m ); - /* add in "bpy" as a default module */ - PyDict_SetItemString(d, "bpy", Main_Init() ); + /* add in "bpy" as a default module + * This has been disabled, import like Blender*/ + /*PyDict_SetItemString(d, "bpy", M_BPy_Init() );*/ EXPP_dict_set_item_str( d, "__import__", import ); } diff --git a/source/blender/python/api2_2x/Main.c b/source/blender/python/api2_2x/BPyModule.c index 276d0b04660..6a49aa56a79 100644 --- a/source/blender/python/api2_2x/Main.c +++ b/source/blender/python/api2_2x/BPyModule.c @@ -34,7 +34,7 @@ #include "MEM_guardedalloc.h" /* for MEM_callocN */ #include "DNA_space_types.h" /* SPACE_VIEW3D, SPACE_SEQ */ #include "DNA_scene_types.h" -#include "DNA_object_types.h" /* MainSeq_new */ +#include "DNA_object_types.h" /* LibBlockSeq_new */ #include "DNA_texture_types.h" #include "DNA_curve_types.h" #include "DNA_ipo_types.h" @@ -103,7 +103,7 @@ #include "Text.h" #include "Sound.h" #include "NLA.h" -#include "Main.h" +#include "BPyModule.h" #include "Scene.h" #include "Library.h" @@ -115,22 +115,22 @@ #include "DNA_screen_types.h" -static PyObject *MainSeq_CreatePyObject( Link *iter, int type ) +static PyObject *LibBlockSeq_CreatePyObject( Link *iter, int type ) { - BPy_MainSeq *seq = PyObject_NEW( BPy_MainSeq, &MainSeq_Type); + BPy_LibBlockSeq *seq = PyObject_NEW( BPy_LibBlockSeq, &LibBlockSeq_Type); seq->iter = iter; seq->type = type; return (PyObject *)seq; } -static int MainSeq_len( BPy_MainSeq * self ) +static int LibBlockSeq_len( BPy_LibBlockSeq * self ) { ListBase *lb = wich_libbase(G.main, self->type); return BLI_countlist( lb ); } -static PyObject * MainSeq_subscript(BPy_MainSeq * self, PyObject *key) +static PyObject * LibBlockSeq_subscript(BPy_LibBlockSeq * self, PyObject *key) { char *name; char *lib= NULL; @@ -188,16 +188,16 @@ static PyObject * MainSeq_subscript(BPy_MainSeq * self, PyObject *key) ( PyExc_KeyError, "Requested data does not exist") ); } -static PyMappingMethods MainSeq_as_mapping = { - ( inquiry ) MainSeq_len, /* mp_length */ - ( binaryfunc ) MainSeq_subscript, /* mp_subscript */ +static PyMappingMethods LibBlockSeq_as_mapping = { + ( inquiry ) LibBlockSeq_len, /* mp_length */ + ( binaryfunc ) LibBlockSeq_subscript, /* mp_subscript */ ( objobjargproc ) 0, /* mp_ass_subscript */ }; /************************************************************************ * - * Python MainSeq_Type iterator (iterates over GroupObjects) + * Python LibBlockSeq_Type iterator (iterates over GroupObjects) * ************************************************************************/ @@ -205,7 +205,7 @@ static PyMappingMethods MainSeq_as_mapping = { * Initialize the interator index */ -static PyObject *MainSeq_getIter( BPy_MainSeq * self ) +static PyObject *LibBlockSeq_getIter( BPy_LibBlockSeq * self ) { /* we need to get the first base, but for selected context we may need to advance to the first selected or first conext base */ @@ -221,15 +221,15 @@ static PyObject *MainSeq_getIter( BPy_MainSeq * self ) self->iter = link; return EXPP_incr_ret ( (PyObject *) self ); } else { - return MainSeq_CreatePyObject(link, self->type); + return LibBlockSeq_CreatePyObject(link, self->type); } } /* - * Return next MainOb. + * Return next LibBlockSeq iter. */ -static PyObject *MainSeq_nextIter( BPy_MainSeq * self ) +static PyObject *LibBlockSeq_nextIter( BPy_LibBlockSeq * self ) { PyObject *object; Link *link; @@ -246,7 +246,7 @@ static PyObject *MainSeq_nextIter( BPy_MainSeq * self ) return object; } -PyObject *MainSeq_getActive(BPy_MainSeq *self) +PyObject *LibBlockSeq_getActive(BPy_LibBlockSeq *self) { switch (self->type) { case ID_SCE: @@ -280,7 +280,7 @@ PyObject *MainSeq_getActive(BPy_MainSeq *self) "Only Scene and Image types have the active attribute" ); } -static int MainSeq_setActive(BPy_MainSeq *self, PyObject *value) +static int LibBlockSeq_setActive(BPy_LibBlockSeq *self, PyObject *value) { switch (self->type) { case ID_SCE: @@ -350,7 +350,7 @@ static int MainSeq_setActive(BPy_MainSeq *self, PyObject *value) "Only Scene and Image types have the active attribute" ); } -static int MainSeq_setTag(BPy_MainSeq *self, PyObject *value) +static int LibBlockSeq_setTag(BPy_LibBlockSeq *self, PyObject *value) { int param = PyObject_IsTrue( value ); ID *id; @@ -390,7 +390,7 @@ Mesh *add_mesh__internal(char *name) } /* used for new and load */ -PyObject *MainSeq_new(BPy_MainSeq *self, PyObject * args, PyObject *kwd) +PyObject *LibBlockSeq_new(BPy_LibBlockSeq *self, PyObject * args, PyObject *kwd) { ID *id = NULL; char *name=NULL, *filename=NULL, *ipo_type; @@ -581,7 +581,7 @@ PyObject *MainSeq_new(BPy_MainSeq *self, PyObject * args, PyObject *kwd) } -PyObject *MainSeq_unlink(BPy_MainSeq *self, PyObject * args) +PyObject *LibBlockSeq_unlink(BPy_LibBlockSeq *self, PyObject * args) { PyObject *pyobj; @@ -660,7 +660,7 @@ PyObject *MainSeq_unlink(BPy_MainSeq *self, PyObject * args) "Only types Scene, Group and Text can unlink" ); } -static int MainSeq_compare( BPy_MainSeq * a, BPy_MainSeq * b ) +static int LibBlockSeq_compare( BPy_LibBlockSeq * a, BPy_LibBlockSeq * b ) { return ( a->type == b->type) ? 0 : -1; } @@ -669,40 +669,40 @@ static int MainSeq_compare( BPy_MainSeq * a, BPy_MainSeq * b ) * repr function * callback functions building meaninful string to representations */ -static PyObject *MainSeq_repr( BPy_MainSeq * self ) +static PyObject *LibBlockSeq_repr( BPy_LibBlockSeq * self ) { - return PyString_FromFormat( "[Main Iterator]"); + return PyString_FromFormat( "[LibBlockSeq Iterator]"); } -static PyGetSetDef MainSeq_getseters[] = { +static PyGetSetDef LibBlockSeq_getseters[] = { {"active", - (getter)MainSeq_getActive, (setter)MainSeq_setActive, + (getter)LibBlockSeq_getActive, (setter)LibBlockSeq_setActive, "active object", NULL}, {"tag", - (getter)NULL, (setter)MainSeq_setTag, + (getter)NULL, (setter)LibBlockSeq_setTag, "tag all data in True or False (write only)", NULL}, {NULL,NULL,NULL,NULL,NULL} /* Sentinel */ }; -static struct PyMethodDef BPy_MainSeq_methods[] = { - {"new", (PyCFunction)MainSeq_new, METH_VARARGS | METH_KEYWORDS, +static struct PyMethodDef BPy_LibBlockSeq_methods[] = { + {"new", (PyCFunction)LibBlockSeq_new, METH_VARARGS | METH_KEYWORDS, "(name) - Create a new object in this scene from the obdata given and return a new object"}, - {"unlink", (PyCFunction)MainSeq_unlink, METH_VARARGS, + {"unlink", (PyCFunction)LibBlockSeq_unlink, METH_VARARGS, "unlinks the object from the scene"}, {NULL, NULL, 0, NULL} }; /*****************************************************************************/ -/* Python MainSeq_Type structure definition: */ +/* Python LibBlockSeq_Type structure definition: */ /*****************************************************************************/ -PyTypeObject MainSeq_Type = { +PyTypeObject LibBlockSeq_Type = { PyObject_HEAD_INIT( NULL ) /* required py macro */ 0, /* ob_size */ /* For printing, in format "<module>.<name>" */ - "Blender MainSeq", /* char *tp_name; */ - sizeof( BPy_MainSeq ), /* int tp_basicsize; */ + "Blender LibBlockSeq", /* char *tp_name; */ + sizeof( BPy_LibBlockSeq ), /* int tp_basicsize; */ 0, /* tp_itemsize; For allocation */ /* Methods to implement standard operations */ @@ -711,14 +711,14 @@ PyTypeObject MainSeq_Type = { NULL, /* printfunc tp_print; */ NULL, /* getattrfunc tp_getattr; */ NULL, /* setattrfunc tp_setattr; */ - ( cmpfunc ) MainSeq_compare, /* cmpfunc tp_compare; */ - ( reprfunc ) MainSeq_repr, /* reprfunc tp_repr; */ + ( cmpfunc ) LibBlockSeq_compare, /* cmpfunc tp_compare; */ + ( reprfunc ) LibBlockSeq_repr, /* reprfunc tp_repr; */ /* Method suites for standard classes */ NULL, /* PyNumberMethods *tp_as_number; */ NULL, /* PySequenceMethods *tp_as_sequence; */ - &MainSeq_as_mapping, /* PyMappingMethods *tp_as_mapping; */ + &LibBlockSeq_as_mapping, /* PyMappingMethods *tp_as_mapping; */ /* More standard operations (here for binary compatibility) */ @@ -751,13 +751,13 @@ PyTypeObject MainSeq_Type = { /*** Added in release 2.2 ***/ /* Iterators */ - ( getiterfunc) MainSeq_getIter, /* getiterfunc tp_iter; */ - ( iternextfunc ) MainSeq_nextIter, /* iternextfunc tp_iternext; */ + ( getiterfunc) LibBlockSeq_getIter, /* getiterfunc tp_iter; */ + ( iternextfunc ) LibBlockSeq_nextIter, /* iternextfunc tp_iternext; */ /*** Attribute descriptor and subclassing stuff ***/ - BPy_MainSeq_methods, /* struct PyMethodDef *tp_methods; */ + BPy_LibBlockSeq_methods, /* struct PyMethodDef *tp_methods; */ NULL, /* struct PyMemberDef *tp_members; */ - MainSeq_getseters, /* struct PyGetSetDef *tp_getset; */ + LibBlockSeq_getseters, /* struct PyGetSetDef *tp_getset; */ NULL, /* struct _typeobject *tp_base; */ NULL, /* PyObject *tp_dict; */ NULL, /* descrgetfunc tp_descr_get; */ @@ -780,50 +780,46 @@ PyTypeObject MainSeq_Type = { }; -/*-----------------------Main module Init())-----------------------------*/ +/*-----------------------------BPy module Init())-----------------------------*/ -static char M_Main_doc[] = "The Blender.Main submodule"; +static char M_BPy_Init_doc[] = "The bpy module"; -PyObject *Main_Init( void ) +void M_BPy_Init( void ) { - PyObject *submodule; + PyObject *module; PyObject *dict; - - - if( PyType_Ready( &MainSeq_Type ) < 0 ) - return NULL; - if( PyType_Ready( &Config_Type ) < 0 ) /* see Config.c */ - return NULL; - submodule = Py_InitModule3( "Blender.Main", NULL, M_Main_doc ); - dict = PyModule_GetDict( submodule ); + + PyType_Ready( &LibBlockSeq_Type ); + PyType_Ready( &Config_Type ); + + /*submodule = Py_InitModule3( "Blender.Main", NULL, M_Main_doc );*/ + module = Py_InitModule3( "bpy", NULL, M_BPy_Init_doc ); + dict = PyModule_GetDict( module ); PyDict_SetItemString( dict, "libraries", Library_Init( ) ); - /* Python Data Types */ - PyModule_AddObject( submodule, "scenes", MainSeq_CreatePyObject(NULL, ID_SCE) ); - PyModule_AddObject( submodule, "objects", MainSeq_CreatePyObject(NULL, ID_OB) ); - PyModule_AddObject( submodule, "meshes", MainSeq_CreatePyObject(NULL, ID_ME) ); - PyModule_AddObject( submodule, "curves", MainSeq_CreatePyObject(NULL, ID_CU) ); - PyModule_AddObject( submodule, "metaballs", MainSeq_CreatePyObject(NULL, ID_MB) ); - PyModule_AddObject( submodule, "materials", MainSeq_CreatePyObject(NULL, ID_MA) ); - PyModule_AddObject( submodule, "textures", MainSeq_CreatePyObject(NULL, ID_TE) ); - PyModule_AddObject( submodule, "images", MainSeq_CreatePyObject(NULL, ID_IM) ); - PyModule_AddObject( submodule, "lattices", MainSeq_CreatePyObject(NULL, ID_LT) ); - PyModule_AddObject( submodule, "lamps", MainSeq_CreatePyObject(NULL, ID_LA) ); - PyModule_AddObject( submodule, "cameras", MainSeq_CreatePyObject(NULL, ID_CA) ); - PyModule_AddObject( submodule, "ipos", MainSeq_CreatePyObject(NULL, ID_IP) ); - PyModule_AddObject( submodule, "worlds", MainSeq_CreatePyObject(NULL, ID_WO) ); - PyModule_AddObject( submodule, "fonts", MainSeq_CreatePyObject(NULL, ID_VF) ); - PyModule_AddObject( submodule, "texts", MainSeq_CreatePyObject(NULL, ID_TXT) ); - PyModule_AddObject( submodule, "sounds", MainSeq_CreatePyObject(NULL, ID_SO) ); - PyModule_AddObject( submodule, "groups", MainSeq_CreatePyObject(NULL, ID_GR) ); - PyModule_AddObject( submodule, "armatures", MainSeq_CreatePyObject(NULL, ID_AR) ); - PyModule_AddObject( submodule, "actions", MainSeq_CreatePyObject(NULL, ID_AC) ); + PyModule_AddObject( module, "scenes", LibBlockSeq_CreatePyObject(NULL, ID_SCE) ); + PyModule_AddObject( module, "objects", LibBlockSeq_CreatePyObject(NULL, ID_OB) ); + PyModule_AddObject( module, "meshes", LibBlockSeq_CreatePyObject(NULL, ID_ME) ); + PyModule_AddObject( module, "curves", LibBlockSeq_CreatePyObject(NULL, ID_CU) ); + PyModule_AddObject( module, "metaballs", LibBlockSeq_CreatePyObject(NULL, ID_MB) ); + PyModule_AddObject( module, "materials", LibBlockSeq_CreatePyObject(NULL, ID_MA) ); + PyModule_AddObject( module, "textures", LibBlockSeq_CreatePyObject(NULL, ID_TE) ); + PyModule_AddObject( module, "images", LibBlockSeq_CreatePyObject(NULL, ID_IM) ); + PyModule_AddObject( module, "lattices", LibBlockSeq_CreatePyObject(NULL, ID_LT) ); + PyModule_AddObject( module, "lamps", LibBlockSeq_CreatePyObject(NULL, ID_LA) ); + PyModule_AddObject( module, "cameras", LibBlockSeq_CreatePyObject(NULL, ID_CA) ); + PyModule_AddObject( module, "ipos", LibBlockSeq_CreatePyObject(NULL, ID_IP) ); + PyModule_AddObject( module, "worlds", LibBlockSeq_CreatePyObject(NULL, ID_WO) ); + PyModule_AddObject( module, "fonts", LibBlockSeq_CreatePyObject(NULL, ID_VF) ); + PyModule_AddObject( module, "texts", LibBlockSeq_CreatePyObject(NULL, ID_TXT) ); + PyModule_AddObject( module, "sounds", LibBlockSeq_CreatePyObject(NULL, ID_SO) ); + PyModule_AddObject( module, "groups", LibBlockSeq_CreatePyObject(NULL, ID_GR) ); + PyModule_AddObject( module, "armatures", LibBlockSeq_CreatePyObject(NULL, ID_AR) ); + PyModule_AddObject( module, "actions", LibBlockSeq_CreatePyObject(NULL, ID_AC) ); /* Other Types */ - PyModule_AddObject( submodule, "config", Config_CreatePyObject() ); - - return submodule; + PyModule_AddObject( module, "config", Config_CreatePyObject() ); } diff --git a/source/blender/python/api2_2x/Main.h b/source/blender/python/api2_2x/BPyModule.h index f1dd6c0782e..ea11cce9810 100644 --- a/source/blender/python/api2_2x/Main.h +++ b/source/blender/python/api2_2x/BPyModule.h @@ -1,5 +1,4 @@ /* - * $Id$ * * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** * @@ -30,16 +29,16 @@ * ***** END GPL/BL DUAL LICENSE BLOCK ***** */ -#ifndef EXPP_MAIN_H -#define EXPP_MAIN_H +#ifndef EXPP_BPYMODULE_H +#define EXPP_BPYMODULE_H #include <Python.h> /* The Main PyType Object defined in Main.c */ -extern PyTypeObject MainSeq_Type; +extern PyTypeObject LibBlockSeq_Type; -#define BPy_MainSeq_Check(v) \ - ((v)->ob_type == &MainSeq_Type) +#define BPy_LibBlockSeq_Check(v) \ + ((v)->ob_type == &LibBlockSeq_Type) /* Main sequence, iterate on the libdatas listbase*/ typedef struct { @@ -47,9 +46,9 @@ typedef struct { Link *iter; /* so we can iterate over the listbase */ short type; /* store the ID type such as ID_ME */ -} BPy_MainSeq; +} BPy_LibBlockSeq; -PyObject *Main_Init( void ); +void M_BPy_Init( void ); #endif /* EXPP_MAIN_H */ diff --git a/source/blender/python/api2_2x/Blender.c b/source/blender/python/api2_2x/Blender.c index d940b6eb2c7..9423eb27c5c 100644 --- a/source/blender/python/api2_2x/Blender.c +++ b/source/blender/python/api2_2x/Blender.c @@ -93,7 +93,6 @@ struct ID; /*keep me up here */ #include "Window.h" #include "World.h" #include "Types.h" -#include "Main.h" /**********************************************************/ /* Python API function prototypes for the Blender module. */ @@ -987,6 +986,5 @@ void M_Blender_Init(void) PyDict_SetItemString(dict, "Texture", Texture_Init()); PyDict_SetItemString(dict, "Window", Window_Init()); PyDict_SetItemString(dict, "World", World_Init()); - PyDict_SetItemString(dict, "Main", Main_Init()); } diff --git a/source/blender/python/api2_2x/doc/API_intro.py b/source/blender/python/api2_2x/doc/API_intro.py index dbc8e13e7d5..4e2c71f3afc 100644 --- a/source/blender/python/api2_2x/doc/API_intro.py +++ b/source/blender/python/api2_2x/doc/API_intro.py @@ -12,7 +12,7 @@ The Blender Python API Reference ----------- - L{Blender} - - L{bpy<Bpy>} (automatically imported) + - L{bpy<Bpy>} Submodules: ----------- diff --git a/source/blender/python/api2_2x/doc/Bpy.py b/source/blender/python/api2_2x/doc/Bpy.py index 25eca7ab6a8..ef755c64976 100644 --- a/source/blender/python/api2_2x/doc/Bpy.py +++ b/source/blender/python/api2_2x/doc/Bpy.py @@ -60,10 +60,10 @@ Example:: import os sound_dir = '/home/me/soundfiles/' sounds_new = [] - for filename in os.listdir(sound_dir): - if filename.lower().endswith('.wav'): + for fname in os.listdir(sound_dir): + if fname.lower().endswith('.wav'): try: - snd = bpy.sounds.load(sound_dir + filename) + snd = bpy.sounds.new(filename = sound_dir + fname) except: snd = None @@ -93,50 +93,50 @@ Example:: Window.RedrawAll() @var scenes: iterator for L{scene<Scene.Scene>} data -@type scenes: L{dataIterator} +@type scenes: L{LibBlockSeq} @var objects: iterator for L{object<Object.Object>} data -@type objects: L{dataIterator} +@type objects: L{LibBlockSeq} @var meshes: iterator for L{mesh<Mesh.Mesh>} data -@type meshes: L{dataIterator} +@type meshes: L{LibBlockSeq} @var curves: iterator for L{curve<Curve.Curve>} data -@type curves: L{dataIterator} +@type curves: L{LibBlockSeq} @var metaballs: iterator for L{metaball<Metaball.Metaball>} data -@type metaballs: L{dataIterator} +@type metaballs: L{LibBlockSeq} @var materials: iterator for L{material<Material.Material>} data -@type materials: L{dataIterator} +@type materials: L{LibBlockSeq} @var textures: iterator for L{texture<Texture.Texture>} data -@type textures: L{dataIterator} +@type textures: L{LibBlockSeq} @var images: iterator for L{image<Image.Image>} data -@type images: L{dataIterator} +@type images: L{LibBlockSeq} @var lattices: iterator for L{lattice<Lattice.Lattice>} data -@type lattices: L{dataIterator} +@type lattices: L{LibBlockSeq} @var lamps: iterator for L{lamp<Lamp.Lamp>} data -@type lamps: L{dataIterator} +@type lamps: L{LibBlockSeq} @var cameras: iterator for L{camera<Camera.Camera>} data -@type cameras: L{dataIterator} +@type cameras: L{LibBlockSeq} @var ipos: iterator for L{ipo<Ipo.Ipo>} data -@type ipos: L{dataIterator} +@type ipos: L{LibBlockSeq} @var worlds: iterator for L{world<World.World>} data -@type worlds: L{dataIterator} +@type worlds: L{LibBlockSeq} @var fonts: iterator for L{font<Font.Font>} data -@type fonts: L{dataIterator} +@type fonts: L{LibBlockSeq} @var texts: iterator for L{text<Text.Text>} data -@type texts: L{dataIterator} +@type texts: L{LibBlockSeq} @var sounds: iterator for L{sound<Sound.Sound>} data -@type sounds: L{dataIterator} +@type sounds: L{LibBlockSeq} @var groups: iterator for L{group<Group.Group>} data -@type groups: L{dataIterator} +@type groups: L{LibBlockSeq} @var armatures: iterator for L{armature<Armature.Armature>} data -@type armatures: L{dataIterator} +@type armatures: L{LibBlockSeq} @var actions: iterator for L{action<NLA.Action>} data -@type actions: L{dataIterator} -@var libraries: L{New library<LibData>} submodule -@type libraries: L{New library<LibData>} +@type actions: L{LibBlockSeq} +@var libraries: L{librarySeq<LibData>} submodule +@type libraries: L{librarySeq<LibData>} """ -class dataIterator: +class LibBlockSeq: """ Generic Data Access =================== @@ -208,21 +208,28 @@ class dataIterator: - L{texts} This can also be used to set the active data. - >>> bpy.images.active = bpy.images.load('/home/me/someimage.jpg') + >>> bpy.images.active = bpy.images.new(filename = '/home/me/someimage.jpg') """ - def new(name): + def new(name="", filename=""): """ - This function returns a new datablock + This function returns a new datablock containing no data or loaded from a file. Exceptions ========== - - Images optionally accept 2 extra arguments: bpy.images.new(name, width=256, height=256) + + Use the filename keyword string values to load data from a file, this works with L{images}, L{texts}, L{sounds}, L{fonts} only. + + >>> sound = bpy.sounds.new('newsound', '~/mysound.wav') # uses the first string given for the name. + + >>> sound = bpy.sounds.new(filename = '~/mysound.wav') # will use the filename to make the name. + + + Images optionally accept 3 arguments: bpy.images.new(name, width=256, height=256) The width and height must br between 4 and 5000 if no args are given they will be 256. - Ipos need 2 arguments: bpy.ipos.new(name, type) type must be a string can be + Ipos need 2 arguments: bpy.ipos.new(name, type) type must be a string (use in place of filename) can be... - 'Camera' - 'World' - 'Material' @@ -243,17 +250,6 @@ class dataIterator: @rtype: datablock """ - - def load(filename): - """ - This function loads a new datablock from a file. - applies to: - - L{fonts} - - L{sounds} - - L{images} - Other types will raise an error. - @rtype: datablock - """ def unlink(datablock): """ |