diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-05-24 19:21:14 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-05-24 19:21:14 +0400 |
commit | 357ce169589d70b610865a76788a1f1756ff231c (patch) | |
tree | 4771bfd9885fa979dc72633c0f9a2402e8952e14 /doc/python_api/examples | |
parent | a8cb91e64a4e46df081a36715dbcc7f98475c047 (diff) |
loading data with bpy.data.libraries.load(), now swaps out the strings in the list to load with the actual datablocks, this is convenient because it saves the script author having to find them after.
also raise warnings rather then errors if the datablock can't be found.
Diffstat (limited to 'doc/python_api/examples')
-rw-r--r-- | doc/python_api/examples/bpy.types.BlendDataLibraries.load.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/doc/python_api/examples/bpy.types.BlendDataLibraries.load.py b/doc/python_api/examples/bpy.types.BlendDataLibraries.load.py index 43e6ac90ae7..f78728cefc8 100644 --- a/doc/python_api/examples/bpy.types.BlendDataLibraries.load.py +++ b/doc/python_api/examples/bpy.types.BlendDataLibraries.load.py @@ -21,3 +21,19 @@ with bpy.data.libraries.load(filepath, link=True) as (data_from, data_to): with bpy.data.libraries.load(filepath) as (data_from, data_to): for attr in dir(data_to): setattr(data_to, attr, getattr(data_from, attr)) + + +# the 'data_to' variables lists are +with bpy.data.libraries.load(filepath) as (data_from, data_to): + data_to.scenes = ["Scene"] + + +# 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 bpy.data.libraries.load(filepath) as (data_from, data_to): + data_to.meshes = data_from.meshes +# now operate directly on the loaded data +for mesh in mdata_to.meshes: + if mesh is not None: + print(mesh.name) |