# Merge Long Line Segment into Smaller Overlapping Lines

All, I am trying to find a way if possible to merge and split a long line and merge it into the smaller lines which overlap it. Basically need to split the long line at smaller lines points and merge at those locations. While also leaving the remaining lengths which do not overlap. I have another list with a value associated to the lines, so if i can get the lines to split and merge, i also want the other list to add together too. Can anyone point me in a direction or possible python thoughts which would do that?

like this

cut for each start and endpoint ?

KR

Andreas

@Draxl_Andreas Yes, that is the direction i would like to go. Is there a solution which provides that? Thank you much!

Hello, here is a possibility

edit:

Here with python code (to improve, Iām still a novice)
we must be able to improve, very certainly but I admit that I have trouble with the use of function lambda)

import sys
import clr
from Autodesk.DesignScript.Geometry import *
#Inputs
long_line=[IN[0]]
short_lines=IN[1]
#Find the points
Pts=[] #Container
Pts_sorted=[]
Pts=[Curve.PointAtParameter(i,0) for i in short_lines[0]]
Pts.extend(Curve.PointAtParameter(i,1) for i in short_lines[0])
Pts.extend(Curve.PointAtParameter(j,0) for j in long_line)
Pts.extend(Curve.PointAtParameter(j,1) for j in long_line)
#Pts_sorted=sorted(Pts,key=lambda x:x=Curve.ParameterAtPoint(long_line[0],x))
OUT = Pts

edit2:
I found with lambda

import sys
import clr
from Autodesk.DesignScript.Geometry import *
#Inputs
long_line=[IN[0]]
short_lines=IN[1]
def cond(lin,pts):
return Curve.ParameterAtPoint(lin,pts)

short_lines[0].extend(long_line)
list_lines=short_lines[0]
#Find the points
Pts=[Curve.PointAtParameter(i,j) for i in list_lines for j in [0,1]]
#Sorted the points
Pts_sorted=sorted(Pts,key=lambda x:cond(long_line[0],x))
#Polycurve
Pol= PolyCurve.ByPoints(Pts_sorted,False)

OUT = Pol

Cordially
christian.stan

2 Likes