Avoid holes on a polysurface when generating tool-paths

Hi everyone,

I am working on automatically creating tool-paths on polysurfaces. The assumption is - I get a CAD, I pick a side I am interested in and define it as an open polysurface. I give it to my grasshopper script and its supposed to churn out a scanning tool-path either in horizontal lines or in vertical lines. So far so good, I’ve even added some parameters to be able to set distances between points & between lines.

Now the problem arises when I have to traverse holes. I can’t just fly over them and need to stay on the surface.



As you can see, when using “brep closest point”, the point that is in a hole gets pushed to the closest point on the border, however the distance between the points can become quite large. Furthermore, if i hit the hole exactly right (going through the center approximately), the line ends up going over the hole with technically no points on the hole.
While this might work with parameter tuning, I would prefer taking the holes into account and simply generating a circular segment around them. I am unfortunately at a loss as to how to do it, because this is a polysurface and the second large hole is not picked up when examining the borders of the largest surface, thus the curve also does not cross the path lines since it is on a different plane.

Here’s my simplified grasshopper file with the polysurface embedded:
scanner_trajectories_for_forum.gh (123.7 KB)

P.S. the tiny holes are not a problem, they can be treated with the current script and wont break my tool. The big holes are a problem because they are bigger than the tool and there’s a chance to hit the border after flying over the hole.

I’d be extremely grateful for any suggestions on how to tackle this!
And let me know if there’s any additional info needed to understand why I did what I did so far (but mostly the answer will be - don’t know any better, I am very much a beginner in grasshopper)