Removing collections through the Blender Python API

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

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:

4.5 2 votes
Article Rating
Notify of

2 Comment
Oldest Most Voted
Inline Feedbacks
View all comments
Rombout Versluijs
9 months ago

WHy is there no code for moving an collection?
I can seem to find any code for that, do you know ant perhaps