Sometimes it is useful to get summary information about scene objects in Blender in the form of a simple table, allowing us to quickly inspect the scene and identify objects that require further improvement. We can collect such statistics using a simple script.
As an example, let’s collect statistics for selected meshes. We’ll record the number of vertices, edges, and polygons for each mesh in the table, allowing us to quickly identify high-poly meshes that could require some improvements.
Define a list to store our statistics.
|
1 |
stat = [] |
Loop through all the selected objects in the scene.
|
1 |
for obj in bpy.context.selected_objects: |
Using Blender Python API, we can easily get the number of vertices, edges, and polygons for each current object. However, before getting the statistics, we need to “evaluate” each object to account for changes made to objects through modifiers and geometry nodes.
We can get a pointer to the evaluated object using the Depsgraf.
|
1 2 3 |
obj_data = obj.evaluated_get(bpy.context.evaluated_depsgraph_get()).data # bpy.data.meshes['Mesh'] |
Using the obtained pointer, we can get the full statistics for the current object, including its number of points, edges, and polygons, and add this information to our statistics list.
|
1 |
stat.append([obj.name, len(obj_data.vertices), len(obj.data.edges), len(obj_data.polygons)]) |
After filling the statistics list in a loop through the selected objects, we can sort the resulting list for easier control. For example, by the number of vertices (the second element in our statistics list).
|
1 |
stat = sorted(stat, key = lambda item: item[1], reverse=True) |
The reverse order is needed so that the objects with the largest number of points, which we will optimize later, appear at the beginning of the list.
Save the resulting table as a simple text file.
|
1 2 3 4 |
with open('_FILE_PATHNAME_.txt', 'w') as f: f.write('Name\tVerts\tEdges\tFaces\n') for item in stat: f.write(f'{item[0]}\t{item[1]}\t{item[2]}\t{item[3]}\n') |
Now we can open the saved file for viewing. The heaviest meshes will be located in the first rows.
In addition to the number of vertices, polygons, and edges, we can add any data we need for monitoring to our statistics table.
Using tabs as delimiters is convenient because such data can be easily transferred to a spreadsheet program, such as Excel, by simply copying and pasting (Ctrl+c/Ctrl+v).

.blend file on Patreon