Select Meshes by number of Faces

Hi. Is there a way to select meshes by their number of faces? Thanks.

H

Here I’ve wrote a python script to help you achieve what you are looking for:

from Rhino import *
from Rhino.DocObjects import *
from scriptcontext import doc
import rhinoscriptsyntax as rs
faceCount = rs.GetInteger("Number of faces", 100, 1)
object_enumerator_settings = ObjectEnumeratorSettings()
object_enumerator_settings.ClassTypeFilter =  DocObjects.MeshObject
rhino_objects = doc.Objects.GetObjectList(object_enumerator_settings)
for rhino_object in rhino_objects:
    if (rhino_object.Geometry.GetNgonAndFacesCount() == faceCount):
        rs.SelectObject(rhino_object)

hayden.py (509 Bytes)

1 Like

Thanks but I think I’m doing something wrong. It does not seem to work.

What version of Rhino are you using?
Do you get any error message?

Try this one:

from Rhino import *
from Rhino.DocObjects import *
from scriptcontext import doc
import rhinoscriptsyntax as rs
faceCount = rs.GetInteger("Number of faces", 100, 1)
object_enumerator_settings = ObjectEnumeratorSettings()
object_enumerator_settings.ClassTypeFilter =  DocObjects.MeshObject
rhino_objects = doc.Objects.GetObjectList(object_enumerator_settings)
for rhino_object in rhino_objects:
    if (rs.MeshFaceCount(rhino_object) == faceCount):
        rs.SelectObject(rhino_object)

hayden.py (495 Bytes)

hayden

1 Like

I’m on R6. No errors. Just nothing happens.

Exploding a mesh dosen’t tell you anything about number of it’s faces.

1 Like

You are a star! Thank you!

Thanks for this script! I modified to select all meshes with “greater than” number of faces. That way I can select and reduce faces and exclude simple meshes that will get completely destroyed if I try to reduce by 80%.

My models can contain components that have way too much detail, like 800k+ polys. Some of them are boxes, 12 polys, and others are nuts, bolts, washers, with one set having around 8000+ polys. Reducing polys by 80% on the small detailed objects works great (because they’re all good closed meshes), but if any boxes with 12-40 polys are selected they get destroyed.

Thanks again!!

This came in useful today. Thanks again.