With Rhinocommon, how can I find hole location on a surface?


I am trying to find the location of holes (cylinder) on a rectangular surface.

My thought right now is to create lines running parallel and perpendicular to one side of the edge until it reaches the other edge. Basically creating a grid. Then if the line intersects with the hole, I’ll retrieve the hole (cylinder) object, then from there I’ll try to determine its relative location.

Would like to ask if there’s any other way to do this? Any suggestions for this, as I am fairly new to Rhinocommon api, thank you.

There are multiple solutions. It depends on how robust the script needs to be.

A trimmed surface is always a Brep. So it has BrepEdges.
Just by looking at you example you could say that (assuming its that simple) the brep edges of the cutouts are 1.) shorter 2.) periodic 3.) curved 4.) inside the u and v domain of underlying surface. They are probally 5.) weighted (if circular) and 6.) they are not touching the edges of the surface etc.

Depending on the use-case, checking for one of the mentioned properties should be enough to detect them.

These holes can be found with DuplicateNakedEdgeCurvers(bool,bool) like so:

Brep b; // this is your Brep with holes
Curve[] innerEdges = b.DuplicateNakedEdgeCurves(false, true);

See https://developer.rhino3d.com/api/rhinocommon/rhino.geometry.brep/duplicatenakededgecurves

1 Like

Hi @Syracs,

Here is a fairly robust example you might consider.

– Dale