[Bf-python] Adding a new way to deal with libraries

Ken Hughes khughes at pacific.edu
Tue Mar 13 06:49:13 CET 2007


Campbell Barton wrote:

> in regards to bpy.libraries
> 
> typedef struct {
>     PyObject_VAR_HEAD /* required python macro */
>     char filename[FILE_MAXDIR + FILE_MAXFILE]
> } BPy_Lib;
> 
> a library wouldnt be linked to anything, just a filename...
> 
> so "for lib in bpy.libraries" - would only return a list or iterator of 
> of open libraries, as you point out, its not THAT usefull...

So it's just a placeholder for the filename and some methods to link or 
append data from those files.  Which also means .load() is misleading; 
we could just as well say "lib = bpy.library.define('//file.blend')" or 
something.

> When dealing with libs, the Python API would have to deal with loading 
> and unloading the blend files, this would be done whenever the lib-data 
> was accessed. so the user removing a file is ok. just return an error 
> next time its accessed.
> 
> a BPy_Lib isnt realy linked into bpy.libraries, so new bpy.libraries 
> could be created..
> 
> lib = bpy.libraries.load('//mylib.blend')
> 
> then the scripter could load some data from the lib, and it would then 
> become a part of bpy.libraries

"become a part of"... do you mean "bpy.libraries.materials" could now be 
used to access the materials in a library we load?

> lib filenames should also be writable..
> 
> lib.filename = '//....' - this would inspect blender for a name matching 
>  "lib" and rename its filename to the assigned one..

Don't get this.  Can you give a better example?

Ken



More information about the Bf-python mailing list