Quantcast
Channel: Scripting - McNeel Forum
Viewing all articles
Browse latest Browse all 4148

Create cross section failed

$
0
0

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]
    else:
        section = sec[1]
    return section

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

else:
    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)
            intersects.append(intersect)
            for crv in cross_sect_crvs:
                cross_section_crvs.append(crv)
            for pt in cross_sect_pts:
                cross_section_pts.append(pt)
        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!
Vincent

2 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 4148

Trending Articles