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
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()
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
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