Help with script, split curves with picked points?

any idea why this isn’t working? thank you

or a better alternative to select some curves, then pick points to split them at?

Option Explicit
'Script written by <insert name>
'Script copyrighted by <insert company name>
'Script version Friday, October 01, 2010 12:50:16 PM

Call SplitCrvsWithPts()
Sub SplitCrvsWithPts()
	
	Dim arrCurve,arrIdPoints,arrPoints,str,el

	arrCurve = rhino.getobjects("select curves to split",,, True)
  

	If Rhino.IsCurve(arrCurve) Then

		Rhino.Print "The object is a curve."




		arrPoints = rhino.getPoints(,, "put Points on curves")
		rhino.enableRedraw vbfalse
		str = ""
		For Each el In arrcurve
			str = str & "selid " & el & " "
		Next
		arrIdPoints = rhino.addpoints(arrpoints)


		rhino.command("_split " & str & " enter selpt _enter")
		rhino.deleteObjects arrIdPoints
		rhino.enableredraw vbtrue
	End If
	
	End Sub

Hi @kleerkoat,

Here is a simple Python version:

import rhinoscriptsyntax as rs

def split_curve_at_points():
    
    curve_id = rs.GetObject("Select curve to split", rs.filter.curve)
    if not curve_id: return
    
    points = []
    while True:
        point = rs.GetPointOnCurve(curve_id)
        if point:
            points.append(point)
        else:
            break
            
    if len(points) == 0: return
    
    parameters = []
    for point in points:
        t = rs.CurveClosestPoint(curve_id, point)
        parameters.append(t)
    
    pieces = rs.SplitCurve(curve_id, parameters)
    if pieces:
        rs.DeleteObject(curve_id)
        
if __name__ == "__main__":
    split_curve_at_points()

– Dale

try changing these two lines:
arrCurve = rhino.getobjects("select curves to split",,, True)
If Rhino.IsCurve(arrCurve) Then
to:
arrCurve = rhino.getobjects("select curves to split", 4,, True)
If Not isnull(arrCurve) Then

thanks Dale, Jarek got me on track

nailed it! thank you!

i still can’t get it to work on multi curves

now your isn’t working

what’s the error/problem ?

it only selects one curve, i’d like to pick multiple crvs and then place poims on them. instead of doing one my one.

ty

this works fine over here:

Option Explicit

Call SplitCrvsWithPts()
Sub SplitCrvsWithPts()
	
	Dim arrCurve,arrIdPoints,arrPoints,str,el

	arrCurve = rhino.getobjects("Curves to split?", 4,, True)
	
	If Not isnull(arrCurve) Then

		arrPoints = rhino.getPoints(,, "put Points on curves")
		If isnull(arrPoints) Then Exit Sub

		Rhino.enableRedraw False
		str = ""
		For Each el In arrcurve
			str = str & "selid " & el & " "
		Next
		arrIdPoints = rhino.addpoints(arrpoints)
		rhino.command("_split " & str & " enter selpt _enter")
		rhino.deleteObjects arrIdPoints
		rhino.enableredraw True
	End If
	
End Sub