Split/ Trim solids inside a closed curve

Hey guys,

Is there a script out there that will trim anything within a closed boundary like a closed curve including solids?

Or anything to one side of an open curve?

Mitch, I know your MaqueTool Multiboundary Trim Curve will trim curves inside a closed curve, but I’m trying to find a way to trim solids…

Thank you.

Does this do what you’re looking for?

solidCutter.py (1023 Bytes)

import rhinoscriptsyntax as rs

toCut = rs.GetObjects("Select Solids to Cut", filter = rs.filter.polysurface)
wire = rs.GetObject("Select Closed Planar Curve as Cutter", filter = rs.filter.curve)

if toCut is not None:
        centroidPt = rs.CurveAreaCentroid(wire)[0]
        basePlane = rs.CurvePlane(wire)
        print("Cutting object must be closed planar curve")

    for target in toCut:
        bb = rs.BoundingBox(target)
        l = (rs.Distance(bb[0], bb[6]))*2+rs.Distance(bb[0],centroidPt)
        extrudUp = rs.ExtrudeCurveStraight(wire, centroidPt, rs.PointAdd(centroidPt, basePlane.ZAxis*l))
        extrudDown = rs.ExtrudeCurveStraight(wire, centroidPt, rs.PointAdd(centroidPt, basePlane.ZAxis*l*-1))
        extruds = rs.JoinSurfaces([extrudUp, extrudDown])
        trimmed = rs.BooleanIntersection(target, extruds)
        rs.DeleteObjects([extrudUp, extrudDown, extruds])

Hi Owen,

Awesome! This works but right now it keeps what’s inside the closed curve.

Is there a way to modify it so it asks you whether you want to keep what’s inside the closed curve or outside the closed curve? Anotherwords, to give you the choice.

Thank you.


Sure, no problem. Like this?

solidCutter_02.py (1.2 KB)

1 Like

Exactly! Thank you very much!! I really appreciate it.

I tried it but it doesn’t work, I did something wrong


Please post a Rhino file and not just an image. Impossible to tell what the objects are in your image, are they curves, surfaces or solids?