# 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,domU)
u=rs.GetReal(msg,(domU+domU)/2,minimum=domU,maximum=domU)
msg="Enter a V parameter value - range is from {} to {}".format(domV,domV)
v=rs.GetReal(msg,(domV+domV)/2,minimum=domV,maximum=domV)
pt=rs.EvaluateSurface(srf,u,v)
``````

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,dom)
param=rs.GetReal(msg,minimum=dom,maximum=dom)
pt=rs.EvaluateCurve(crv,param)