How can you filter out surfaces with holes in them

Trying to select building polygons with holes in them. I’d like to be able to do it by deleting all surfaces with no holes in them or by deleting any with more than one boundary edge.

An example of the relevant Object Description entry of a polygon with a hole…


  • Valid surface.*
  • trimmed surface with 1 hole(s).*
  •  Plane Surface*
  •    "U":  (-88.6005 <= U <= 49.1221)*
  •    "V":  (-20.8729 <= V <= 65.323)*
  • Edge Tally:*
  •  2 boundary edges*

An example of a polygon with no holes that we would like to select and delete…


  • Valid surface.*
  • trimmed surface.*
  •  Plane Surface*
  •    "U":  (0 <= U <= 100.965)*
  •    "V":  (-68.8136 <= V <= 33.5264)*
  • Edge Tally:*
  •  1 boundary edges*

Is there a way to filter out surface by number of boundary edges or by having holes in them and how would one go about doing this?

Ideally there would be a way of doing this without resorting to Grasshopper.

My bad. I didn’t look at here.

Hi @oscar.rodriguez ,
You can use len() instead of the counter function.
Basically if there are more than 2 closed curves it means one must be a hole (since 1 is the border).
You should loop all the faces if you are dealing with solids

import Rhino
import rhinoscriptsyntax as rs
import clr
import System
def counter(objs):
    for obj in objs :
    return i
def select_surfaces_with_holes():
    surfaces = rs.GetObjects()
    surfaces_with_holes = []
    for surfacex in surfaces:
        brep_face = surface.Faces[0]
        all_loops = brep_face.Loops
        # If the number of all loops is greater than the number of outer loops, the surface has a hole
        if counter(all_loops) > 1:


Hope this helps.

1 Like