Split the lines by points

Hi,

I am trying to split the lines with a list of intersected points and then remove the lines between the points. My idea is to create a list of lines with intersected points and then compare two lists of lines and filter out the overlapping lines. But I have no idea how to check if it overlaps or not. Could you give me some idea, or another way to filter out the lines? thanks.

Thanks,

Chop the point list into pairs → transpose → line by 2 points


1 Like

And a python option for you to try :slightly_smiling_face:

# Load the Python Standard and DesignScript Libraries
import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

line = IN[0]  # Single line
points = IN[1]  # Flat list of points

# Create line segments from subsequent points plus remainders
if len(points) == 0:
    OUT = [line]  # No points, return original line
else:
    # Sort points by their parameter along the line
    def get_parameter(point):
        return line.ParameterAtPoint(point)
    
    sorted_points = sorted(points, key=get_parameter)
    
    line_segments = []
    
    # Add segment from line start to first point (if needed)
    first_param = get_parameter(sorted_points[0])
    if first_param > 0:
        start_segment = Line.ByStartPointEndPoint(line.StartPoint, sorted_points[0])
        line_segments.append(start_segment)
    
    # Add segments between consecutive points
    for i in range(len(sorted_points) - 1):
        segment = Line.ByStartPointEndPoint(sorted_points[i], sorted_points[i + 1])
        line_segments.append(segment)
    
    # Add segment from last point to line end (if needed)
    last_param = get_parameter(sorted_points[-1])
    if last_param < 1:
        end_segment = Line.ByStartPointEndPoint(sorted_points[-1], line.EndPoint)
        line_segments.append(end_segment)
    
    OUT = line_segments