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)

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!