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.
This commit is contained in:
2011-05-24 15:21:14 +00:00
parent a8cb91e64a
commit 357ce16958
2 changed files with 83 additions and 6 deletions

View File

@@ -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)