Python – Comparing each item in array into another ( Dynamo )


I’m new to programming and only started writing my first lines of code last week.

I’m writing a script in a program called dynamo, this is to be used in my project. After some research, it appears like I need to use python.

What I need to script to do is look at a bunch of lines ( In a program called Revit), pick up the geometry of this line and then detect if any other line has a start point or end point that is in contact with that geometry. I then want to Split that line at that point, this can be done byCurve.SplitByPoints but I need some kind of way to compare ALL lines to ALL start/end points then the output be in a way that the output can be used to split the curve by the point. I can have the line and the point in which to cut in.

I tried to explain that the best I could…

code :

import clr
from Autodesk.DesignScript.Geometry import *

dataEnteringNode = IN
Line = IN[0]                    #Line
LPS = IN[1]                     # Line Point Start
LPE = IN[2]                     # Line Point End
LPC = IN[3]                     # Line Point Combined // Maybe not needed
T = 100                         # Tolerance of Intersection
INT1 = []                       # Blank Variable for First Loop Results
INT2 = []                       # Blank Variable for First Loop Results
result1 = []                    # Blank Variable for Second Loop Results
result2 =[]                     # Blank Variable for Second Loop Results

for i in range (0,len(LPS)):
distance = Curve.DistanceTo(LPS[i],Line[i])

for i in range (0,len(LPE)):
distance = Curve.DistanceTo(LPE[i],Line[i])

for i in range (0,len(INT1)):
if INT1 > T:

for i in range (0,len(INT2)):
if INT2 > T:

    Assign your output to the OUT variable.
    OUT = result1, result2


Sorry, I knew explaining this would be tricky for me.

I’ll attempt to simplify it.

I want something like:

if curve intersect with StartPoint or EndPoint
     Curve.split points(Curve,Intersecting_Point)

So im hoping something similar will have it so, when a start or end point intersects a curve, the curve will be split into 2 curves at that point.

So I want to above for to work on a range of lines. I drew a diagram and attempted to upload, but for some reason, it now says I need 10 rep to post an image. meaning I cant upload a new diagram and had to remove the ones I had in?

Thanks for the help! I’m sorry for my explaination skills


Sorry but both what you’re trying to do and what problem(s) you get are quite unclear. Please simplify your code to a MCVE ( and post example inputs and expected outputs.
And really, takes a bit time to learn Python – at least the basics like how to iterate over a list 😉
What exactly is your question? Does your script fail or provide incorrect results? If you are looking for a general algorithm, try to write a minimum working example without the Revit code, if your problem is not with Revit itself.