Identifying untrimmed surfaces (with "orphan" edges)

We seem to have a constant problem with the users missing small surface trims. When we send the surface files to CNC, these untrimmed surfaces become a problem. Here is an example:

I’ve been asked to come up with an easy way to flag these errors to prevent them from happening. I have an idea, but I don’t know if it’s possible as a script. Basically, what every untrimmed surface has in common is that it has an edge that doesn’t touch another edge.

Here’s the question: Is there a way to have Rhino raise a flag when there is a surface that has an edge that doesn’t touch another (perhaps within a specified tolerance)?



Is this different than ShowEdges identifying Naked edges?

Very different. Our models are not closed polysurfaces. If they were, that would be a great solution.



I guess that your surfaces are obtained by exploding merged polysurfaces object/body.
By inspecting polysurface before exploding you should easily identify “problem” edges (naked / non-manifold)

No, these models were never closed polysurfaces. Our process differs from the traditional product designer’s. We work back from automotive data received from our customers to design and build our gauging. We could take the time to repair and join all the nasty edges we end up with, but then we would never process 60,000 CNC details a year that we do.

Are you using Grasshopper? Here’s one approach with a C# script in GH (the code can also be used in a Rhino plugin, or translated to python script):

Fig 1. All surfaces added to the brep list and OrphanEdges are listed in the output:

Fig 2. Testing all the (disjoint) surfaces in the picture gives the following result (black balls are test points on mid-edges, and yellow pipes highlight “Orphan Edges”): (76.1 KB)

Edit: + parallel version. (78.1 KB)

// Rolf

1 Like

This will tell you if a surface is trimmed or not:

Downside is it will flag all untrimmed surfaces, so you will need to find a way or logic to determine not only if the surface is not trimmed, but also if it was meant to not be trimmed. If that matters in your models.

You could add this to the beginning of @RIL script to filter out all the untrimmed surfaces first to then do the edge test on less surfaces.

Hi @Michael_Pryor, I just tried it but It seems to me that the script works for both trimmed and untrimmed surfaces. Perhaps this is because I pick edge-midpoints and tests only for surface.ClosestPoint(mid_pt) and if the distance is never within a tolerance the edge is considered being an “orphan” (good term?).

Perhaps I don’t know what you mean here?

Edit: Also, if there are very many surfaces to test, I can make a parallel version.

// Rolf

Say you have 200 surfaces and 10 are untrimmed. You could use IsSurface to first find the 10 untrimmed surfaces. Then run your edge test on only those 10 surfaces to the edges of the 200 to see what is orphaned. Otherwise you test 200 surfaces vs 200 surfaces. The results should be the same but maybe it is faster.

I just tried 1050 surfaces, it took 11.5 sec :

I’ll try a Parallel version to see how much I can bring it down. One could also break after first Orphan and then redo. That’ll probably be superfast… :slight_smile:

Edit: With the parallel version it took 3.6 sec.

// Rolf

1 Like

Sure, but maybe filtering helps as well. Just a thought.

This looks pretty close to what I have in mind. But I know nothing about Grasshopper. Is there a way to extract code from Grasshopper so I can make a Python version?

If you double click @RIL component in grasshopper you can access the code.

It’s not really a question of whether or not a surface is trimmed. It’s whether or not the edge is “orphaned” as Rolf puts it. There could be scenarios where the surface is trimmed, but not correctly.

There could be scenarios where the surface is trimmed, but not correctly.


Thanks. I will give that a try in the morning.

I guess my thread title was a bit deceptive. Sorry. You addressed what I requested, I just requested the wrong thing! I like the term “orphaned” edges.

I added a parallel version. I tested with 1050 surfaces (trying all their edges) which required 2.8 million tests, which took ~3.6 seconds in the parallel version.

The new version was added to the original post above.

// Rolf

In general case checking midpoint of an edge against other edges may return min distance < tolerance, but it is still an “Orphan-edge”.
Here is an example where one edge of red surface is “Orphan-edge”:

1 Like

Arghhh. Oh I know; I’ll add a warning text for this case! :wink:

// Rolf