To create a new collection in the scene using the Blender Python API, we need to execute the following:
1 2 3 4 |
import bpy collection = bpy.context.blend_data.collections.new(name='new_collection') bpy.context.collection.children.link(collection) |
In the first line, we create a new collection with the “new_collection” name.
In the second line, we add it to the scene’s collection system under the current active collection.