Hello everyone!
As shown, I want to project two points vertically onto the surface.
I found a similar function from the RHINO SDK C++, such as: RhinoProjectPointsToBreps()
or RhinoProjectPointsToMeshes()
.
I have tried to mesh the surface and use function to project the point. But from the results, it is completely useless.
What I want to know is RhinoProjectPointsToMeshes()
Is this function really able to project points? Or is there any other way I can know the coordinates of the point vertically projected onto the surface?
Thanks for your advice.
Hey,
here is the C# version. For reference you can look at the Surface
class in Rhinocommon
https://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_Geometry_Surface_ClosestPoint.htm
Here is the code, and I also attached the GH file with all data internalized, so if you would like to see a live update, dont forget to input your own points or surface.
private void RunScript(Surface surface, List<Point3d> pts, ref object A)
{
List<Point3d> projectedPoints = new List<Point3d>();
double u;
double v;
for (int i = 0; i < pts.Count; i++)
{
bool cp = surface.ClosestPoint(pts[i], out u, out v);
if(cp)
{
Plane plane;
if (surface.FrameAt(u, v, out plane))
{
projectedPoints.Add(plane.Origin);
}
}
}
A = projectedPoints;
}
I hope it helps
SrfClosestPts.gh (5.7 KB)
Hi @t107408022,
To project one or more points onto a surface, use RhinoProjectPointsToBreps
. If you have an ON_Surface
, then you can construct a Brep from the surface as follows:
ON_Surface* surface = ...
ON_Brep* brep = ON_Brep::New();
brep->Create(surface);
...
delete brep;
See opennurbs_brep.h for more details.
– Dale