Hello,
is there a way to get the uv vector of a surface with python?
Regards,
samid
Hello,
is there a way to get the uv vector of a surface with python?
Regards,
samid
import rhinoscriptsyntax as rs
p = rs.EvaluateSurface(srf, uv.X, uv.Y)
n = rs.SurfaceNormal(srf, uv)
Hi @samid,
If you’re interested in a solution using rhinocommon, you could try the following:
import Rhino.Geometry as rg
# Get the UV-values
test, u, v = surface.ClosestPoint(point)
if test: # if successful...
srf_pt = surface.PointAt(u, v) # get surface point
srf_normal = surface.NormalAt(u, v) # get surface normal
normal.gh (6.5 KB)
Have a nice week-end!
Mahdiyar and P1r4t3b0y thank you for the answers. I know how to get surface normals but it is not what I need. I need the u and v as vector. Or maybe I understand here something wrong?
You mean something like this?
import rhinoscriptsyntax as rs
plane = rs.SurfaceFrame(srf, uv)
uVector = plane.XAxis
vVector = plane.YAxis
Hi Mahdiyar,
your way was also my way but then I noticed that it’s not the same. When you create a rectangular surface, copy it and change at one of them the normal. The you have two surfaces with same u and v direction but different normal direction. If you now try to evaluate a point on both surfaces then you will get same u and v directions but different planes. That’s the reason why I need the u and v directions and not the plane itself.
import Rhino.Geometry as rg
success, pt, vectors = srf.Evaluate(uv.X, uv.Y, 1)
if(success):
uVector, vVector = vectors
uVector.Unitize()
vVector.Unitize()
samid.gh (23.6 KB)
Thank you, I will try it out on monday and give an answer. Have a nice weekend.
Hi Mahdiyar,
perfect it works. Thank you.
Regards,
samid