Split curve with two points intervall


#1

I would like to split and then trim a curve between two points interval.

In python we need to use domains to specify the position of the cutting point the thing is just the maximum vs minimum values…

The question is if I get the curve domain; is the sequence always following the minimum and maximum values meaning the first item of the list is also always the minimum and the second item is always the maximum.

I noticed that the Rhino gave me the length of the curve as curve maximum domain but sometimes it is 1.0.

The second question is how can we get the exact position of the minimum domain specified by point coordinates? I understand that we can get start and end point of the curve but is the minimum domain refers to start of the curve and the end point refers to the maximum domain? Always?

I have found this link useful from clement:


(NARUTO) #2

Hi Onrender
Curve domain is the parameter evaluation value,You can set it yourself.like this


Curve parameters can be redefined,like this

You can use the PointAt() method of the Curve class to find the position of a point.

Split curve with two points intervall
You can use the Split() method of the Curve class to split curve with two points intervall.like this

Split curve with two points intervall.gh (12.3 KB)


#3

Thank you, I am interested rhino python script only without gh.


(NARUTO) #4
import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino.Geometry as rg


new_Domain =rg.Interval(0,1)


curve_guid = rs.GetObject("Select a curve",rs.filter.curve)
if(curve_guid):
    curve_geo = rs.coercecurve(curve_guid)
    curve_geo.Domain = new_Domain
    sc.doc.Objects.AddPoint(curve_geo.PointAt(0.2))
    sc.doc.Objects.AddPoint(curve_geo.PointAt(0.7))
    curves = curve_geo.Split((0.2,0.7))
    if(curves):
        rs.DeleteObject(curve_guid)
        for i in curves:
            sc.doc.Objects.AddCurve(i)
            sc.doc.Views.Redraw()

like this

you can use CurveClosestPoint function find a ”t“


#5

Thank you, I am actually looking fro the value of the domain at a given point.

I have found it, yes the closest point will be the solution.