U value at point on curve

How do I evaluate the U (parameter) value of a point on a curve? This is directly equivalent to evaluating the UV values of a point on a surface using EvaluateUVPt.

Also, how do I create a point on a curve (corrected from surface) at a specified U (parameter) value? This is directly equivalent to creating a point on a surface using PointsFromUV.

You can use Rhinoscript or python for this… The function is CurveClosestPoint().

import rhinoscriptsyntax as rs
crv=rs.GetObject("Select curve",4,True)
pt=rs.GetPointOnCurve(crv,"Pick point")
param=rs.CurveClosestPoint(crv,pt)
print "The parameter at pick point is {}".format(param)

You will need both the U and V values, the function is EvaluateSurface()…

import rhinoscriptsyntax as rs
srf=rs.GetObject("Select surface",8,True)
domU=rs.SurfaceDomain(srf,0)
domV=rs.SurfaceDomain(srf,1)
msg="Enter a U parameter value - range is from {} to {}".format(domU[0],domU[1])
u=rs.GetReal(msg,(domU[0]+domU[1])/2,minimum=domU[0],maximum=domU[1])
msg="Enter a V parameter value - range is from {} to {}".format(domV[0],domV[1])
v=rs.GetReal(msg,(domV[0]+domV[1])/2,minimum=domV[0],maximum=domV[1])
pt=rs.EvaluateSurface(srf,u,v)
rs.AddPoint(pt)

HTH, --Mitch

Mitch, thanks for the scripts. The second question had a mistake, now corrected. I meant to ask about creating a point on a curve, not a surface, at a specified U value so I still need a way to do that.

One question out of curiosity though; what does the second script, EvaluateSurface(), do that the PointsFromUV does not do?

Hi David,

You can drop this button onto your Rhino. Left button click will evaluate the curve parameter for picked point, right button parameter would add the point for the entered curve parameter.
evalCrv.rui (6.3 KB)

PointsFromUV command can add multiple points. It can also input normalized parameters (from 0 to 1), and also has an option not to add the point, but instead print its coordinates.

That’s kind of the inverse of the first script… The function in this case is EvaluateCurve() which takes a parameter and returns a point. ClosestPoint() takes a point and returns a parameter.

import rhinoscriptsyntax as rs
crv=rs.GetObject("Select curve",4,True)
dom=rs.CurveDomain(crv)
msg="Enter value between {} and {}".format(dom[0],dom[1])
param=rs.GetReal(msg,minimum=dom[0],maximum=dom[1])
pt=rs.EvaluateCurve(crv,param)
rs.AddPoint(pt)

Nothing, it’s just the rhinoscript equivalent - and as djordje says, the native Rhino command has some more options, which is often the case.

–Mitch