Delete all empty meshes

From The Foundry MODO SDK wiki
Jump to: navigation, search

Description:

Delete all meshes in the scene that do not contain any vertexes.

Thanks for the help to Bernd Möller and Ivo!

Code:

import modo
scene = modo.Scene()
 
# write all items that do not contain any vertexes in a list
itemList = [item for item in scene.items(itype='mesh', superType=True) if item.geometry.internalMesh.PointCount() == 0]
 
 
print ("Following Meshes have been deleted: " + str(itemList))                                                               # Output the names of the deleted Meshes for the user
scene.removeItems(itemList)                                                                                                  # Delete all meshes that were collected in the list