How to Locate a Point Along Curve or Surface at a Distance/Offset?

Hi folks, any suggestions appreciated. I regularly run into this issue where I need to locate a point for a construction that falls some distance away from a location along an irregular curve or surface. Like this simple case :

Looks like there is a function in RhinoScript : Rhino - Distance on a Curve from a Point - but nothing that I’ve seen that is accessible within standard Rhino commands. Does anyone know of anything - (alternately maybe I should undertake getting familiar with the encapsulating Rhino script into a button to use like a command?)

(eta - when attempting to run the linked script it’s erroring out with an undefined domain error, (not sure if I’m missing some input conditions))

Ideally whatever solution would work generally on 2D and 3D curvature, (in the case of 3D suppose there needs to be an additional vector given as well).

It looks there was a minor typograhpical error regarding dom. After correcting the spelling miskate, the script runs normally as domonstrated below.

Call OffsetPointOnCurve()
Sub OffsetPointOnCurve
 
	' Select the curve
	Dim crv : crv = Rhino.GetObject("Select curve", 4)
	If IsNull(crv) Then Exit Sub
 
	' Select a point on the curve to offset from      
	Dim pt : pt = Rhino.GetPointOnCurve(crv, "Select point on curve")
	If IsNull(pt) Then Exit Sub
 
	' Specify the offset distance    
	Dim dist : dist = Rhino.GetReal("Distance to offset point")
	If IsNull(dist) Then Exit Sub
 
	' Get the closest point on the curve from the test point      
	Dim t : t = Rhino.CurveClosestPoint(crv, pt)
 
	' Get the curve's domain
	Dim dom : dom = Rhino.CurveDomain(crv)
 
	' Get the total length of the curve
	Dim l : l = Rhino.CurveLength(crv)
 
	' Determine the length from the start of the curve to the test point
	Dim ls : ls = Rhino.CurveLength(crv,, Array(Dom(0), t))
 
	' Offset a point in each direction    
	Rhino.AddPoint Rhino.CurveArcLengthPoint(crv, ls + dist, True)
	Rhino.AddPoint Rhino.CurveArcLengthPoint(crv, l - ls + dist, False)
 
	' Add the test point for reference
	Rhino.AddPoint pt
 
End Sub

Sure, you can achieve it using the RunScript. Please copy below script into a button dialog box, and fyi.

! -RunScript (
 
Call OffsetPointOnCurve()
Sub OffsetPointOnCurve
 
	' Select the curve
	Dim crv : crv = Rhino.GetObject("Select curve", 4)
	If IsNull(crv) Then Exit Sub
 
	' Select a point on the curve to offset from      
	Dim pt : pt = Rhino.GetPointOnCurve(crv, "Select point on curve")
	If IsNull(pt) Then Exit Sub
 
	' Specify the offset distance    
	Dim dist : dist = Rhino.GetReal("Distance to offset point")
	If IsNull(dist) Then Exit Sub
 
	' Get the closest point on the curve from the test point      
	Dim t : t = Rhino.CurveClosestPoint(crv, pt)
 
	' Get the curve's domain
	Dim dom : dom = Rhino.CurveDomain(crv)
 
	' Get the total length of the curve
	Dim l : l = Rhino.CurveLength(crv)
 
	' Determine the length from the start of the curve to the test point
	Dim ls : ls = Rhino.CurveLength(crv,, Array(Dom(0), t))
 
	' Offset a point in each direction    
	Rhino.AddPoint Rhino.CurveArcLengthPoint(crv, ls + dist, True)
	Rhino.AddPoint Rhino.CurveArcLengthPoint(crv, l - ls + dist, False)
 
	' Add the test point for reference
	Rhino.AddPoint pt
 
End Sub
)

Here is an old script of mine that offsets multiple points along a curve… FWIW.

OffsetPointsAlongCrv.py (3.7 KB)

Thanks @jessesn & @Helvetosaur for the tips.

For the sake of posterity - from what I’m seeing now - it looks like there actually isn’t a syntax error, but rather - that the problem occurs if the input point has less than the offset distance available in either direction.

(I had been attempting to run the script with an line endpoint as the point location) - in any case the original linked script appears to function fine so long as there exists sufficient curve distance in both directions from the originating point location to allow for a valid output.

In this regard - @Helvetosaur your Python script seems slightly more usable in that it can take an endpoint on a curve as input, provided it is located at the start position wrt the direction of the curve.