Divide a curve with points

Hello everyone,
I want to divide a curve with several points,and divide the new curve into several segments. For example I have a circle. I want to divide it into two parts(green one and yellow one)with the two blue points.And the Yellow part have 5 segments, the green part have 2.

Now I have two questions:
1.with my Python code I can only pick one point and will not correct divide the curve. Like the picture, the yellow part and the black part.

  1. wenn I split the new curve, Everytime I can split a curve ,then restart the Python code again. But I try to figure it out like this, pick a curve then give the number of the Segments, then pick the next one until every curve have been finished.

here is my Python code and Grasshooper Document.

Test.gh (2.7 KB)

import Rhino
from scriptcontext import doc
def SplitByPoints():
    filter = Rhino.DocObjects.ObjectType.Curve
    rc, objref = Rhino.Input.RhinoGet.GetOneObject("Select curve to divide", False, filter)
    if rc != Rhino.Commands.Result.Success: return rc
    curve = objref.Curve()
    if not curve: return Rhino.Commands.Result.Failure
    parameters = []
        gp = Rhino.Input.Custom.GetPoint()
        gp.SetCommandPrompt("Points on curve")
        gp.Constrain(curve, True)
        if gp.CommandResult() == Rhino.Commands.Result.Cancel:
        if gp.CommandResult() == Rhino.Commands.Result.Success:
            t = gp.PointOnCurve()[1]
    curves = curve.Split(parameters)
    for c in curves:
        n = Rhino.Input.RhinoGet.GetInteger("Number of segments", False, 1)[1]
        parameters = c.DivideByCount(n, True)
        for t in parameters:
    return Rhino.Commands.Result.Success

if __name__=="__main__":

SplitByPoints.py (1.2 KB)

Thanks Mahdiyar!

That is great! This is exactly what I need!

But the

gp.SetCommandPrompt(“Points on curve”)

what’s this? I don’t find that in Rhino.commands

It Sets prompt message that appears in the command prompt window:

Hey Mahdiyar.
Could I ask you a related question?
I just change the

curves = curve.Split(parameters)



just like the Picture, and I get the error:

Runtime error (ArgumentTypeException): expected IEnumerable[Curve], got PolylineCurve

I can not understand why I can’t use Joincurves?

I’m not sure if I understood what you’re trying to do. You ask the user to select a curve so there would be (at most) one curve, and obviously, it is not possible to join only one curve.

On the other hand, It seems you’re using GhPython editor, and then asking the user to select a curve in Rhino. Why don’t you simply use your component inputs?