Difference between revisions of "Snippet:Delete all empty meshes"

From The Foundry MODO SDK wiki
Jump to: navigation, search
 
Line 14: Line 14:
 
scene.removeItems(itemList)                                                                                                  # Delete all meshes that were collected in the list
 
scene.removeItems(itemList)                                                                                                  # Delete all meshes that were collected in the list
 
</syntaxhighlight>
 
</syntaxhighlight>
|lang=Python Examples,
+
|lang=Python Examples, TD SDK Examples,
 
}}
 
}}

Latest revision as of 10:18, 26 November 2015

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