2
$\begingroup$

Is there any access in the python API to get the total scene (or object) polygon count?

This info is already displayed in the status bar, but is this info exposed in the python API or do I need to manually loop through all objects and count the faces?

status bar

$\endgroup$

1 Answer 1

10
$\begingroup$

OK twitter to the rescue!

Here's my solution:

bpy.context.scene.statistics(bpy.context.view_layer) gets you the same string as shown in the status bar, so to get the triangle count this just needs to be parsed:

s = bpy.context.scene.statistics(bpy.context.view_layer) tris = int(s.split("Tris:")[1].split(' ')[0].replace(',', '')) 

This is obviously dependent on the view, so it only includes the visible objects in the current view layer.

If you only want to know the tris of a specific object you can hide everything else or just enter edit mode.

$\endgroup$
2
  • $\begingroup$ Was about to post that, beat me to it. ;) $\endgroup$ Commented May 17, 2021 at 11:19
  • $\begingroup$ Do you know of a way to get that while in edit mode on an object? In that mode the command returns the statistics for the selected objects only. $\endgroup$ Commented Sep 20, 2022 at 9:59

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.