Blender Asked by Johan vd Koppel on January 14, 2021
I want to append a collection and the objects within that collection from a blender file, using bpy.data.libraries.load
. The reason to use bpy.data.libraries.load
is to avoid using a bpy.ops
operator, which will make the python script slow. If I load a collection from the blender file using the code below, the collection remains empty.
MainDir = bpy.path.abspath("//")
filename='Plants/Forbs collection.blend'
with bpy.data.libraries.load(MainDir + filename) as (data_from, data_to):
data_to.collections = [c for c in data_from.collections if c=="Woodland forbs"]
for new_coll in data_to.collections:
instance = bpy.data.objects.new(new_coll.name, None)
instance.instance_type = 'COLLECTION'
instance.instance_collection = new_coll
bpy.context.scene.collection.objects.link(instance)
Does anyone have a suggestion?
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP