Download

Static Mesh Triangle Count

Hello,

I’m wondering if anyone knows a way to get the triangle count of a static mesh through python.

Thanks!

Not sure if this is the best way, but this is the solution I’m using:

triangle_count = 0

num_sections = static_mesh.get_num_sections(0)
for section_number in range(num_sections): section_data = unreal.ProceduralMeshLibrary.get_section_from_static_mesh(static_mesh, 0, section_number)
triangle_count += len(section_data[1])

total_triangles = triangle_count / 3

If anyone finds a more elegant solution, feel free to add it here.



import unreal

assets = unreal.EditorUtilityLibrary.get_selected_assets() 
for asset in assets:
    full_name = asset.get_full_name()
    asset_path = str(asset).split(' ')[1]
    mesh = unreal.load_asset(asset_path)
    vert_count = int(unreal.EditorStaticMeshLibrary.get_number_verts(mesh, 0))
    print("Vert count for ", full_name ,vert_count)