Split an object with a line

Hi!
I need to split an object using a line and delete the left side. How can I do it automatically using the python script?Example.3dm (65.4 KB)

Moved to Scripting category so it will be seen.

Hi @matteo2.agostini,

Let me know if this code sample is helpful:

import rhinoscriptsyntax as rs

#
# Split a curve with a cutting curve
#
def test_split_curve():
    
    # Select the curve to split
    curve = rs.GetObject("Select curve to split", rs.filter.curve)
    if curve is None: return
    
    # Select the curve to use as the cutter
    cutter = rs.GetObject("Select cutting curve", rs.filter.curve)
    if cutter is None: return
    
    # Intersect the curve with the cutter
    intersection_list = rs.CurveCurveIntersection(curve, cutter)
    if intersection_list is None: return
    
    # Look for point intersections
    parameters = []
    for intersection in intersection_list:
        if intersection[0] == 1: # point
            parameters.append(intersection[5]) # first curve parameter
            
    if len(parameters) == 0: return
    # To split a closed curve you need at least 2 parameters
    if rs.IsCurveClosed(curve) and len(parameters) < 2: return
    
    # Split the curve
    rc = rs.SplitCurve(curve, parameters)
    if rc:
        rs.DeleteObject(curve) # optional

# Check to see if this file is being executed as the "main" python
# script instead of being used as a module by some other python script
# This allows us to use the module which ever way we want.
if __name__ == "__main__":
    test_split_curve()

– Dale

Thank you very much!! It’s perfect.

Matteo