To get the number of vertices, edges, and polygons in a mesh, we can simply take their amount from the desired data block: “vertices”, “edges”, and “polygons”. However, there is no special data block for triangles in the mesh structure.
To get the number of triangles in the mesh, we need to execute the following code:
For the active object:
1 2 3 4 |
obj = bpy.context.active_object print(sum(len(polygon.vertices) - 2 for polygon in obj.data.polygons)) # 968 |
Or we can use counting mesh triangles through its loop structure:
1 2 3 4 5 6 7 8 |
import bpy obj = bpy.context.active_object obj.data.calc_loop_triangles() print(len(obj.data.loop_triangles)) # 968 |
The image shows the triangle already in that list, yet it has one less than you code?
Why run this action when it shows the triangles?
I guess you want it for selection only right
The title image is only for beauty. The formula is right.