4
The bpy.libraries submodule.
9
This module provides access to objects stored in .blend files. With it scripts
10
can append from Blender files to the current scene, like the File->Append
11
menu entry in Blender does. It allows programmers to use .blend files as
12
data files for their scripts.
14
@warn: This module is new and being considered as a replacement for the
15
L{original Library<Library>} module. Users should stay tuned to see
16
which module is supported in the end.
21
scn= bpy.scenes.active # get current scene
22
lib = bpy.libraries.load('//file.blend') # open file.blend
23
ob = scn.objects.link(lib.objects.append('Cube')) # append Cube object from library to current scene
24
mat = lib.objects.link('Material') # get a link to a material
25
me = ob.getData(mesh=1) # get mesh data
26
me.materials[0] = mat # assign linked material to mesh
31
Select an existing .blend file for use as a library. Unlike the
32
Library module, multiple libraries can be defined at the same time.
34
@type filename: string
35
@param filename: The filename of a Blender file. Filenames starting with "//" will be loaded relative to the blend file's location.
37
@return: return a L{Library} object.
44
This class provides a unified way to access and manipulate library types
46
It provides access to scenes, objects, meshes, curves, metaballs,
47
materials, textures, images, lattices, lamps, cameras, ipos, worlds,
48
fonts, texts, sounds, groups, armatures, and actions.
49
@ivar filename: The path to the library
50
@type filename: string
51
@ivar scenes: library L{scene<Scene.Scene>} data
52
@type scenes: L{LibData}
53
@ivar objects: library L{object<Object.Object>} data
54
@type objects: L{LibData}
55
@ivar meshes: library L{mesh<Mesh.Mesh>} data
56
@type meshes: L{LibData}
57
@ivar curves: library L{curve<Curve.Curve>} data
58
@type curves: L{LibData}
59
@ivar metaballs: library L{metaball<Metaball.Metaball>} data
60
@type metaballs: L{LibData}
61
@ivar materials: library L{material<Material.Material>} data
62
@type materials: L{LibData}
63
@ivar textures: library L{texture<Texture.Texture>} data
64
@type textures: L{LibData}
65
@ivar images: library L{image<Image.Image>} data
66
@type images: L{LibData}
67
@ivar lattices: library L{lattice<Lattice.Lattice>} data
68
@type lattices: L{LibData}
69
@ivar lamps: library L{lamp<Lamp.Lamp>} data
70
@type lamps: L{LibData}
71
@ivar cameras: library L{camera<Camera.Camera>} data
72
@type cameras: L{LibData}
73
@ivar ipos: library L{ipo<Ipo.Ipo>} data
74
@type ipos: L{LibData}
75
@ivar worlds: library L{world<World.World>} data
76
@type worlds: L{LibData}
77
@ivar fonts: library L{font<Font.Font>} data
78
@type fonts: L{LibData}
79
@ivar texts: library L{text<Text.Text>} data
80
@type texts: L{LibData}
81
@ivar sounds: library L{sound<Sound.Sound>} data
82
@type sounds: L{LibData}
83
@ivar groups: library L{group<Group.Group>} data
84
@type groups: L{LibData}
85
@ivar armatures: library L{armature<Armature.Armature>} data
86
@type armatures: L{LibData}
87
@ivar actions: library L{action<NLA.Action>} data
88
@type actions: L{LibData}
93
Generic Library Data Access
94
===========================
95
This class provides access to a specific type of library data.
100
Append a new datablock from a library. The new copy
101
is added to the current .blend file.
103
B{Note}: Blender Objects cannot be appended or linked without linking
104
them to a scene. For this reason, lib.objects.append() returns a
105
special "wrapper object" which must be passed to Scene.objects.link()
106
or bpy.scenes.active.link() in order to actually create the object.
107
So the following code will not create a new object::
110
scn= bpy.scenes.active # get current scene
111
lib = bpy.libraries.load('//file.blend') # open file.blend
112
pseudoOb = lib.objects.append('Cube')) # get an object wrapper
116
scn= bpy.scenes.active # get current scene
117
lib = bpy.libraries.load('//file.blend') # open file.blend
118
pseudoOb = lib.objects.append('Cube')) # get an object wrapper
119
ob = scn.objects.link(pseudoOb) # link to scene
121
@return: return a Blender datablock or object
122
@raise IOError: library cannot be read
123
@raise ValueError: library does not contain B{name}
128
Link a new datablock from a library. The linked data is not copied
129
into the local .blend file.
131
See L{append} for notes on special handling of Blender Objects.
133
@return: return a Blender datablock or object
134
@raise IOError: library cannot be read
135
@raise ValueError: library does not contain B{name}