 # Get distance between 2 points on line

Hi,
Greetings!

How to find distance between two points on curve

for example:
I need to find distance between a and b

The straight distance between a and b is around 11.453, but i need to know distance between a and b on curve, i.e., (10.484 + 15.629) around 26.113 ( that is blue + yellow). Is there any python function to find that ?. Please find the attached cad file for reference. Thank you

File find_distance.stp (10.0 KB)

Here I wrote a simple script that can do what you want:

``````import rhinoscriptsyntax as rs
import Rhino.Geometry as rg
curve = rs.GetCurveObject("Select a curve")
pt1 = rs.GetPointOnCurve(curve, "Select first point")
pt2 = rs.GetPointOnCurve(curve, "Select second point")

a = rs.CurveClosestPoint(curve, pt1)
b = rs.CurveClosestPoint(curve, pt2)

if a > b:
a , b = b , a

distance = rg.Curve.GetLength(rs.coercecurve(curve), rg.Interval(a, b))
print "d1 = " + str(distance)
if rs.IsCurveClosed(curve):
print "d2 = " + str(rs.CurveLength(curve) - distance)
``````

sumuk.py (522 Bytes)

1 Like

Hello - In plain Rhino use `Length` > SubCurve.

-Pascal

3 Likes

Thanks a lot

1 Like