[python] Finding closed curves inside a closed curve

Is there any method to find all closed curves fully inside a closed curve? i.e. not intersecting, not touching.

All curves are planar.

Hmm :thinking: there must be a better way but how about:

  1. make a surface from the enclosing curve
  2. select cuves which intersect with the surface - these are at least partially inside
  3. any of these curves which cannot successfully intersect with the enclosing curves meet your criteria

Thanks for the reply @Dancergraham,

These curves come from a brep-brep intersection (polysurface-surface intersection).

Makes no sense to create a surface again. (my bad I did not clarify this).

I was wondering if there is some method (like select holes) for closed curves to avoid checking each curve’s whereabouts. :wink:


1 Like

Ahaa, you know what, i just figured it out.

from the intersection I get a list of curves.

I’ll create a list of all curves’ lengths. I’ll remove the biggest one (which is the outer contour) and all others are inside. :smiley:

1 Like

You could also just run the SelBoundary command from python.

Hi @siemen,

SelBoundary on the curves?

SelBoundary is view-dependent, so it’s tricky to script…

Only if your object shapes allow you to guarantee the outer curve is the longest. It won’t necessarily always be, e.g. the innermost curve in the intersections of the red plane and the blue polysurface below is actually the longest.

1 Like

:slight_smile: good point, @jeremy5

In my case I’m safe using this, but I’ll keep that in mind.

Selboundary on the outside curve. From your description I understood you already have the outer curve separate.

is this a command? I can’t find it in RhinoCommon.

Ah, I missed this sneaky answer here. We probably posted simultaneously.

This will not work I’ll have to create a loop checking each couple of curves in the list. High complexity :wink: .

Yes, it’s a command.

If all the curves are closed/planar, you could check the area - that would guarantee the outermost one has the biggest area…

1 Like

So the universal solution would be:

  1. check area
  2. check intersection
  3. if no intersection check centroid if it is inside the closed curve with largest area.

Not sure… would this pass your test (centroid marked)? I dont know what you mean by “check area”


1 Like

hmmm :thinking:

No such cases on a ship :stuck_out_tongue_winking_eye: :pirate_flag:

3a. check vertices if they are inside the closed curve with largest area. To reduce complexity do this check only if centroid is inside. And stop this check on the first vertex that appears outside the curve.

Maybe you can give us a better description of what you are trying to accomplish…

This is the original case:


All planar curves. The curves inside are never bigger than the outer contour. I needed only to find a way to identify them and color them and move them to different layers. Which I did with simply getting their lengths.

But, @jeremy5, made the a good point that extended the question to find a more general (universal) solution.