I have 2 collections in a scene (collection, items) both with objects (meshes, camera, lights). How can I select all objecst of type mesh from items and delete them?


With that I can delete all from the scene but I want to limit it to delete all meshes from items. Probably I can if the collection name and type mesh but maybe there is a simpler way?

  • $\begingroup$ @Ray Mairlot, i'm actually trying to convert your Slider Puzzle script from 2014 to blender 2.8 $\endgroup$ – maclaud Sep 25 '19 at 21:45

Don't think there is a simpler way (as you mentioned in the question).


  • Get the collection
  • Iterate over mesh objects in the collection
  • Keep its inner mesh data
  • Remove the object

Then (optional):

  • Iterate over the collected meshes
  • Look if it has became orphean (no user)
  • If yes, delete it

Commented code:

import bpy

collection_name = "items"

# Get the collection from its name
collection = bpy.data.collections[collection_name]

# Will collect meshes from delete objects
meshes = set()

# Get objects in the collection if they are meshes
for obj in [o for o in collection.objects if o.type == 'MESH']:
    # Store the internal mesh
    meshes.add( obj.data )
    # Delete the object
    bpy.data.objects.remove( obj )

# Look at meshes that are orphean after objects removal
for mesh in [m for m in meshes if m.users == 0]:
    # Delete the meshes
    bpy.data.meshes.remove( mesh )
  • $\begingroup$ thanks a lot, that work great for me $\endgroup$ – maclaud Sep 25 '19 at 15:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.