Failure in RemoveHoles of Brep Object

I am attempting to call RemoveHoles on a brep geometry object from python using the Rhino library. When I call RemoveHoles with just the tolerance argument, it creates a brep that is undesirable as it removes all inner loops of all faces. I want to preserve inner loops of faces which are adjacent to other faces. So then I went to calling RemoveHoles with two arguments.

The first argument is supposed to be an IEnumerable. A cast from a list of integers fails. When constructing ComponentIndexes, I first attempted to call ComponentIndex(5, index) using the type for BrepLoops according to documentation. This throws an error which says the type should be 0. When using the type 0 instead, the call return None. (no error) All loop indices supplied are of type inner as well.

Anyone know what I’m doing wrong or if this is a bug?

Hi @jakemurphy0118,

Does Rhino’s UntrimHoles command work?

Can you provide a model, along with your source code, of what isn’t working?


– Dale

UntrimHoles works in many cases, but you still have to play with the maximum edge length per face you use it for. Thanks Dale, here is the geometry I am using for testing and the python file.
untrimInnerHolesExample.3dm (500.4 KB) (684 Bytes)

Hi @jakemurphy0118,

This seems to work:

import rhinoscriptsyntax as rs
import Rhino
import scriptcontext as sc
from System.Collections.Generic import List

obj_id = rs.GetObject()
brep = rs.coercebrep(obj_id)
list = List[Rhino.Geometry.ComponentIndex]()
for loop in brep.Loops:
    if loop.LoopType == Rhino.Geometry.BrepLoopType.Inner:
new_brep = brep.RemoveHoles(list, sc.doc.ModelAbsoluteTolerance)
if new_brep:

Does this help?

– Dale

Hi Dale,

This works great and showed me some other things I didn’t understand. Thanks for your help,