How to shorten a curve by a given length in Rhino Python

rhino
curve
python

#1

Hi, I’am new to Rhino Python.
I’m trying to shorten a curve by a given length. (More specifically cut the first 5 cm form a given curve.)
I am able to find the cutting point by using rs.DivideCurveLength:

newstartpoint=(rs.DivideCurveLength(crv,cutdist,False,True))[1]

But then I’m stuck as I can’t find how to trim a curve with a point.

I guess it would be easier using rs.TrimCurve(). But therefore I need to reparametrize the curve.
Is there a way in Rhino Python to adapt the Curve Domain to [0.0,rs.CurveLength(crv)]?

Thanks for your help and Merry Christmas to all of you!


#2

Hi Jonathan,

There are a couple of ways in which this can be done.
You can do it like you said. You do not need to reparametarize the curve, just find the curve parameter of your newstartpoint by using the rs.CurveClosestPoint function.

Another easier way is to use the rs.ExtendCurveLength function with negative length value:

import rhinoscriptsyntax as rs

crvId = rs.GetObject("pick the curve")
cutdist = 2
extensionSide = 0  # start of the curve
newCrvId = rs.ExtendCurveLength(crvId, 2, extensionSide, -cutdist)

#3

Thank you!