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

Module LibData

source code

The bpy.libraries submodule.

Libraries

This module provides access to objects stored in .blend files. With it scripts can append from Blender files to the current scene, like the File->Append menu entry in Blender does. It allows programmers to use .blend files as data files for their scripts.


Warning: This module is new and being considered as a replacement for the original Library module. Users should stay tuned to see which module is supported in the end.

Example:

       import bpy

       scn= bpy.data.scenes.active                       # get current scene
       lib = bpy.libraries.load('//file.blend')          # open file.blend
       ob = scn.objects.link(lib.objects.append('Cube')) # append Cube object from library to current scene
       mat = lib.objects.link('Material')                # get a link to a material
       me = ob.getData(mesh=1)                           # get mesh data
       me.materials[0] = mat                             # assign linked material to mesh

Classes [hide private]
  Libraries
This class provides a unified way to access and manipulate library types in Blender.
  LibData
This class provides access to a specific type of library data.
Functions [hide private]
Library
load(filename, relative=False)
Select an existing .blend file for use as a library.
source code
List
paths(link=0)
Returns a list of paths used in the current blend file.
source code
 
replace(pathFrom, pathTo)
Replaces an existing directly linked path.
source code
Variables [hide private]
  __package__ = None
Function Details [hide private]

load(filename, relative=False)

source code 

Select an existing .blend file for use as a library. Unlike the Library module, multiple libraries can be defined at the same time.

Parameters:
  • filename (string) - The filename of a Blender file. Filenames starting with "//" will be loaded relative to the blend file's location.
  • relative (boolean) - Convert relative paths to absolute paths (default). Setting this parameter to True will leave paths relative.
Returns: Library
return a Library object.

paths(link=0)

source code 

Returns a list of paths used in the current blend file.

Parameters:
  • link (int) - 0 (default if no args given) for all library paths, 1 for directly linked library paths only, 2 for indirectly linked library paths only.
Returns: List
return a list of path strings.

replace(pathFrom, pathTo)

source code 

Replaces an existing directly linked path.

Parameters:
  • pathFrom (string) - An existing library path.
  • pathTo (string) - A new library path.