.remove(collection), leaves the Meshes

Dear Developers,

i dont know if it is done with a purpose or simply forgotten.
this newby noticed… or is doing something in a wrong manner…

if i use this code to remove a collection.

it removes the collection, the collections inside the collection… plus the objects.
but it leaves the meshes of the objects.

because of this a person has to write extra lines to the script to delete the objects and meshes from each collection, before deleting the collection itself.

so it would be awesome if the command:
would be updated so it also removes the meshes, then people can delete a whole collection with just one line of code…

thank you…

This belongs in the Python API forum, not Blender Development.

This is intended behavior- removal of data doesn’t affect any other data. If you remove an Object, the Mesh/Light/whatever associated with it is not removed. If you want things to be removed completely, either use the corresponding operator to unlink it, or remove the data from the bottom up. There are many situations where you want to remove a collection, object, etc and not touch any other data. Most data in Blender can be referenced by multiple other data types. For example, a mesh can be shared between multiple objects, and an object can be in multiple collections. If collections.remove() deleted all of the associated meshes you would have no way of removing a collection without first moving all of the child objects you wanted to preserve out of the collection (and that would be decidedly more than one line of code).

TLDR: This is just how Blender data works. write yourself a utility function if it’s a hassle.

1 Like

Ok, understand

i was building a script that made a shape of multiple objects, during development of this script it was handy to have a check if the collection already existed and so it had to be deleted, before building the new collections and abjects, also figured out i hd to remove objects from bottom to top…

trying to make sense of Blender…:wink:

thank you…