Removing collections through the Blender Python API

We can delete collections in Blender through the “collections” list in “bpy.data”.

To remove a collection we need to use the “remove” method from the collections list, specifying the collection to be removed in the parameter:

When we delete a collection in this way, all objects from the collection will be unlinked from the scene, but will not be deleted as objects and remain in the blend-file.

To completely remove a collection and all objects in it, we must first delete the objects from the “objects” list, and then delete the collection itself.

This code removes the collection and all nested objects:

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comment
Inline Feedbacks
View all comments