Triangle count

I entered a small contest to model something for a game. So the triangle count had to be kept in check. I found it akward to check the tri count from decimator or ctrl-t, especially if the model was made from separate objects. So, as an exercise, I typed a little script to count the triangles for me.

import Blender
from Blender import *

objektit = Blender.Scene.GetCurrent().getChildren()

print "Number of objects", len(objektit)

total_fc = 0

for obji in objektit:
	if (obji.getType() != 'Mesh'):
		print "Object", obji.getName(), "is not a Mesh, but a", obji.getType()
	obj_fc = 0
	faces = obji.getData().faces
	print "Object", obji.getName(), "has", len(faces), "faces."
	for face in faces:
		obj_fc += (len(face.v)-2)
	print "Those add up to", obj_fc, "triangles.
	total_fc += obj_fc

Draw.PupMenu('Trianglecount: ' + str(total_fc))

print "Total trianglecount:", total_fc

It counts all the faces in all the objects in a scene. Not that usefull, but maybe some starting coders can get a few hints from it or something. I didn’t add the menustuff to yet, and I don’t know if I ever will.

This and newer versions can be found at

… but you can already tell the # of triangles by looking at the # the decimator is set to in the Edit buttons…


And the only problem with that is that you have to do it object by object, then add the counts together. It’s allso quite easy to miss an object.