Skip to content

Instantly share code, notes, and snippets.

@zeffii
Created March 26, 2012 11:08
Show Gist options
  • Save zeffii/2204464 to your computer and use it in GitHub Desktop.
Save zeffii/2204464 to your computer and use it in GitHub Desktop.
how_to_sanitize_a_blend
import bpy
#unselect everything
# <insert code here, this can vary depending on your situation>
# bpy.ops.object.select_all()
# gather list of items of interest.
candidate_list = [item.name for item in bpy.data.objects if item.type == "MESH"]
# select them only.
for object_name in candidate_list:
bpy.data.objects[object_name].select = True
# remove all selected.
bpy.ops.object.delete()
# remove the meshes, they have no users anymore.
for item in bpy.data.meshes:
bpy.data.meshes.remove(item)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment