base class — bpy_struct

class bpy.types.BlendDataLibraries(bpy_struct)

Collection of libraries



Parameters:value (boolean) – Value
load(filepath, link=False, relative=False)

Returns a context manager which exposes 2 library objects on entering. Each object has attributes matching which are lists of strings to be linked.

  • filepath (string) – The path to a blend file.
  • link (bool) – When False reference to the original file is lost.
  • relative (bool) – When True the path is stored relative to the open blend file.
import bpy

filepath = "//link_library.blend"

# load a single scene we know the name of.
with as (data_from, data_to):
    data_to.scenes = ["Scene"]

# load all meshes
with as (data_from, data_to):
    data_to.meshes = data_from.meshes

# link all objects starting with 'A'
with, link=True) as (data_from, data_to):
    data_to.objects = [name for name in data_from.objects if name.startswith("A")]

# append everything
with as (data_from, data_to):
    for attr in dir(data_to):
        setattr(data_to, attr, getattr(data_from, attr))

# the loaded objects can be accessed from 'data_to' outside of the context
# since loading the data replaces the strings for the datablocks or None
# if the datablock could not be loaded.
with as (data_from, data_to):
    data_to.meshes = data_from.meshes
# now operate directly on the loaded data
for mesh in data_to.meshes:
    if mesh is not None:

Inherited Properties

Inherited Functions


Previous topic


Next topic