Module LibData :: Class LibData
[hide private]
[frames] | no frames]

Class LibData

source code

Generic Library Data Access

This class provides access to a specific type of library data.

Instance Methods [hide private]
Blender data
append(name)
Append a new datablock from a library.
source code
Blender data
link(name)
Link a new datablock from a library.
source code
Method Details [hide private]

append(name)

source code 

Append a new datablock from a library. The new copy is added to the current .blend file.

Note: Blender Objects cannot be appended or linked without linking them to a scene. For this reason, lib.objects.append() returns a special "wrapper object" which must be passed to Scene.objects.link() or bpy.data.scenes.active.link() in order to actually create the object. So the following code will not create a new object:

       import bpy

       scn= bpy.data.scenes.active                       # get current scene
       lib = bpy.libraries.load('//file.blend')          # open file.blend
       pseudoOb = lib.objects.append('Cube'))            # get an object wrapper

But this code will:

       import bpy

       scn= bpy.data.scenes.active                       # get current scene
       lib = bpy.libraries.load('//file.blend')          # open file.blend
       pseudoOb = lib.objects.append('Cube'))            # get an object wrapper
       ob = scn.objects.link(pseudoOb)                                   # link to scene
Returns: Blender data
return a Blender datablock or object
Raises:
  • IOError - library cannot be read
  • ValueError - library does not contain name

link(name)

source code 

Link a new datablock from a library. The linked data is not copied into the local .blend file.

See append for notes on special handling of Blender Objects.

Returns: Blender data
return a Blender datablock or object
Raises:
  • IOError - library cannot be read
  • ValueError - library does not contain name