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

Martin Poirier theeth at yahoo.com
Sat Mar 10 16:11:54 CET 2007


--- Campbell Barton <cbarton at metavr.com> wrote:

> it may be that we have deal with 2 sets of lib data
> - data thats 
> currently in blender (as accessed by the outliner) -
> and data that use 
> scripter has loaded, but is yet to be used by
> blender. I think thats ok. 
> if its not used then it wont be there next time
> blender is loaded.

Having virtual data separated from the Blender data
that is loaded from the library on a special call is a
big No No for me.

While lazy linking/appending would be good for batch
process (by that I mean: load library, specify the
data to be linked/appended, link/append all data at
once), I think the default mode should definitely be
atomic load/link/close operations, even if that would
be a bit slower.

> each lib from libraries can be its own pyType thats
> only stores a 
> filename, and has attributes for accessing data
> withing the blend file.
> 
> for ob in lib.objects: could be an list/iterator of
> strings.
> 
> ob = lib.object.link(obname)
> 
> could load the object into blender and return the
> python object.

Also, alternatively, the user could specify a list of
names to link them all at once.

There's the question of where those objects are linked
though. AFAIK, Blender doesn't naturally (that is,
with user interaction) have zero-user objects, though
I'm not sure the internals would really freak out if
that happened. If possible, the objects should be
unlinked to a scene, if not, current scene is probably
a sensible solution. All other data should be unlinked
(if link/appended directly).

> so say you want a group called 'mygroup'
> 
> 
> lib = bpy.libraries.load('//someblend.blend')
> group = lib.groups.link('mygroup')
> 
> 
> again, the logic is a bit weired, because were
> linking to bpy.groups 
> from lib.groups, runnig this command on the source
> is odd.
> 
> 
> maybe it would be more logical to run the add
> command from.
> grp = bpy.groups.link('mygroup', '//mylib.blend')
> 
> and keep lib.groups just a list of names

I like the first solution better.

lib is an external data source with different data
subtypes that each allow linking/appending whereas
bpy.groups (and the like) represents internal data
source (that allow manipulation of those data
elements). Linking/appending from an external source
adds the data into the internal source which can then
be manipulated.

Martin


 
____________________________________________________________________________________
Be a PS3 game guru.
Get your game face on with the latest PS3 news and previews at Yahoo! Games.
http://videogames.yahoo.com/platform?platform=120121



More information about the Bf-python mailing list