Curve Split By Point Function Fail

Hello everyone I hope you are very well, again I am writing in this forum to see if you can help me understand the error of the function that I am creating, I am putting two lists to be able to create the intersection lists.

What I am looking for is to create new lines that are divided by the points and these lines that are unique in the list, I do not know the double iteration between lists causes them to be duplicated between, but I would like to get only the final lines, some advice for correct my code, I would greatly appreciate it.

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

# The inputs to this node will be stored as a list in the IN variables.
SLines= IN[0]
Spoints = IN[1]


#Split Geometry by Points
def SplitLinesBypts(Lines,Points):
	NewLines = []
	for Line in Lines:
		for Point in Points:
			NewLine = Curve.SplitByPoints(Line,Point)
			NewLines.append(NewLine)
	return NewLines

NewCurves= SplitLinesBypts(SLines,Spoints)

OUT= NewCurves

Image of Warning


G-Structural-Grid-Forum-04.dyn (29.7 KB)

SplitByPoints needs an array of points, even if there is only one point. Wrap the Point variable in [ ] brackets, so it will become a 1 length array. Change line 17 to this:

NewLine = Curve.SplitByPoints(Line,[Point])
1 Like

Thank you very much, I understand I little more about these warnings, the problem is that I obtain each result, but I am look the final result. In this case it create one line for each point intersection, so what I can do to obtain only the final list of the lines result of this iteration in the function.


In the image like you see I obtain 95 292 new lines but I only look the unique lines that are spliting by the points, can you give any advice of that?

Yes, because you are splitting all lines by all points, even if they are not on intersecting.

If you have the same number of points and lines, and they are in the same order, you can use enumerate for that:

for Index, Line in enumerate(Lines):
    Newline = Curve.SplitByPoints(Line, [Points[Index]])

This way the nth element of the list of lines will be split by only the nth element of the list of points.

Without knowing the logic of your input lists and what you want to achieve I can’t help more.

1 Like