2
$\begingroup$

Is there a way to display the triangle count of just the visible meshes in the scene and exclude the objects that are hidden? I understand you can go into edit mode on a single mesh to see the triangle count for that mesh, but that's no good for multiple meshes.

any ideas?

cheers

$\endgroup$
  • $\begingroup$ While it doesn't list selected or visible objects, the addon made for this answer shows per object counts for all objects. Might make a change for that. $\endgroup$ – sambler Sep 21 '18 at 6:11
0
$\begingroup$

There is no way to show tris count of only visible objects in Blender, however, you can use Python for that.

If you paste this into a new text block in the text editor and hit Run Script, you will have an operator that you can call from the Space menu if you start typing 'Tris Count For Visible Objects'. You can also copy it into a new text file using any text editor that supports UTF-8 encoding, save it to a .py file and install it as an add-on. It checks all objects in the scene and if they are not hidden in the 3d View and are mesh objects, it counts their triangles and then displays the results as info message in the header of the info panel briefly and in the logs of the info panel:

enter image description here

Here is the code:

bl_info = {
    "name": "Tris Count",
    "author": "Martynas Žiemys",
    "version": (1, 0),
    "blender": (2, 79, 0),
    "location": "Space menu > Tris Count For Visible Objects",
    "description": "Counts tris",
    "warning": "",
    "wiki_url": "",
    "category": "Mesh",
    }

import bpy

class TrisCount(bpy.types.Operator):
    """Tris Count"""
    bl_idname = "scene.tris_count"
    bl_label = "Tris Count For Visible Objects"

    @classmethod
    def poll(cls, context):
        return context.scene is not None

    def execute(self, context):
        tris_count = 0
        for o in bpy.context.scene.objects:
            if o.type == 'MESH' and not o.hide:
                for p in o.data.polygons:
                    if len(p.vertices) > 3:
                        tris_count = tris_count + len(p.vertices) - 2
                    else:
                        tris_count = tris_count +1 
                    pass
        self.report({'INFO'}, 'Tris: ' + str(tris_count))
        return {'FINISHED'}


def register():
    bpy.utils.register_class(TrisCount)


def unregister():
    bpy.utils.unregister_class(TrisCount)


if __name__ == "__main__":
    register()
| improve this answer | |
$\endgroup$
  • $\begingroup$ Hey, That works as a text block in Blender but not when you install it as an add-on. $\endgroup$ – Rob Beddall Sep 19 '18 at 12:43
  • $\begingroup$ I double checked before posting and triple checked just now. It does indeed work as an add-on with 2.79. You need to copy all of the code into a new text file and save it with a .py extension, then open Blender, hit ctrl+alt+u, go to Add-ons tab, hit Install Add-on from File, select the file, hit Enter, find it in the add-ons and check the checkbox to enable it. You can save the preferences if you want it to be enabled next time you launch Blender. It is then accessible from the Space menu as "Tris Count For Visible Objects". $\endgroup$ – Martynas Žiemys Sep 19 '18 at 12:54
  • $\begingroup$ Hey, This is what I'm getting. The console tells me that the script has been installed. It's there on my HD at that location. but it doesn't appear anywhere in the addon menu. gyazo.com/521202fd6ac552bfcca074092e11b634 sorry i don't know how you get the pictures to show on here $\endgroup$ – Rob Beddall Sep 20 '18 at 10:04
  • $\begingroup$ !A pic of my Blender Screen. $\endgroup$ – Rob Beddall Sep 20 '18 at 10:13
  • 1
    $\begingroup$ Sorry, I did say 'any text editor', apparently that does not work. The text needs to be saved using UTF-8 encoding. If you used Blender's Text Editor to save the file it should save it with UTF-8 encoding as far as I know. That should fix it. Sorry for complicating things unnecessarily, I should have just posted a file to download. You can download this one: cdn.rawgit.com/Martynas-Ziemys/Blender-Scripts/master/… $\endgroup$ – Martynas Žiemys Sep 20 '18 at 10:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.