Create cross section failed

Hi all,
I am using Rhino 8 python 3 scripting (Rhino Common) to create a measurement tool for ships.
Among other things, it is meant to create cross sections and measure the surface area.

my current approach to accomplish this, is to create a plane, move the plane to where I want to create the cross section, split it with the objects from the vessel, and measure the surface:

plane = rg.Plane.WorldYZ
plane.Translate(rg.Vector3d(station, 0, 0))
intrvl = rg.Interval(-10 * max_pt.MaximumCoordinate, 10 * max_pt.MaximumCoordinate)
sec_plane = rg.PlaneSurface(plane, intrvl, intrvl)
sec_surf = sec_plane.ToBrep()

sec = sec_surf.Split(ship, 0.01)
section = None
if sec:
    mass_prop_1 = rg.AreaMassProperties.Compute(sec[0])
    mass_prop_2 = rg.AreaMassProperties.Compute(sec[1])
    if mass_prop_1.Area < mass_prop_2.Area:
        section = sec[0]
        section = sec[1]
    return section

However, this split sometimes failes, so I created a back up:

    intersects = []
        cross_section_crvs = [] # rc.CurveList()
        cross_section_pts = []
        for surf in ship:
            intersect, cross_sect_crvs, cross_sect_pts = rgi.Intersection.BrepBrep(surf, sec_surf, 0.01)
            for crv in cross_sect_crvs:
            for pt in cross_sect_pts:
        sec = []
        return rg.Brep().CreateEdgeSurface(cross_section_crvs)

However, even in this case, I sometimes end up with no cross section being created. I have to take the measurements from ~200 ships, with over 100 cross sections per ship, so I am looking at about 20.000 cross sections. And for some reason I am only getting generating around 80% of the required cross sections correctly.

Any ideas what might go wrong, or how I can approach this problem in a different way to get 100% of the cross sections correctly?

Thanks in advance!

Well, generally when a planar surface fails to get created from a series of curves (that you know are coplanar), it’s because there is a gap somewhere. So this might be a function of how your ship models are made - if there are gaps between the surfaces being sectioned, the section curves will not form closed loops and any planar surface creation will fail.

If you are looking for “close enough for area measurement”, you might check the results of your section, and if it’s a single open curve, you could measure the distance between the open ends. If that is within a certain tolerance, close the curve with a line segment or something like that.

One other possible “Hail Mary”* approach to get an approximation - assuming the above fails because you have multiple gaps or something - might be to run MeshPatch on the section curves and measure the mesh area.

*Hail Mary pass - Wikipedia