getting triangle count from python

Is there any way I can get the triangle count of mesh objects using python.
Currently triangle count is displayed on the info tab at the top.

At the very least you can get the number of N-gons in the mesh. Just by getting the length of Mesh.polygons for your mesh. I’m not sure how you would get the triangle count unless your model was already triangulated, you triangulated a copy of it, or you wrote your own script to run though the n-gons and estimate the triangles.

import bpy

obj = bpy.context.active_object
mesh =


import bpy

obj = bpy.context.active_object
mesh =

tri_count = 0
for poly in mesh.polygons:
    if len(poly.vertices) == 3:
        tri_count += 1


note that this is the actual number of triangles “without triangulated quads” , if you want the tri count of a triangulated mesh,then you have to triangulate a copy of the mesh and count its triangles , not sure if there is a method to get all this in the object mesh itself

@ kastoria - Triangle count is already displayed in the ui. Thought that there should be a method to get that through python.

@ MohamedSakr - Thanks for clarifying. Seems like I have to go through your procedure.

you can get that tris count e.g. using this single liner:

int((e for e in bpy.context.scene.statistics().split(" | ") if e.startswith(“Tris:”)).next()[5:])

note that the object needs to be in editmode, or you’ll get scene stats

@ codemanx Ah… Thanks a ton for that!

estimated_tri_count = sum([(len(p.vertices) - 2) for p in])

1 Like

Thx a lot =)