SurfaceClosestPoint - possibility to speed up

Hello, I have a question regarding RhinoScript:

I’m successfully using Excel + VBA + RhinoScript (Rhino version 6) in the field of the hydraulic design of water turbines and pumps.
However, I have a procedure where I need the (u,v) parameters of a large set of points (could be more than 10000 points) of the closest point on a surface.

This works well, but unfortunately the procedure is currently very slow.
The code that slows down the whole application is mainly one loop:

            For i = 0 To nBound
               arrParam(i) = Rhino.SurfaceClosestPoint(strSurface, arrPoints(i))

Is there a possibility to speed up this loop for large number of points?

Remark: I often use the Command: _PointDeviation to verify my results (which is a very similar task).
There I see, that Rhino can handle also very large number of points very fast but I could not figure out how to do the same thing in RhinoScript …

Thanks a lot for your support,


Not that I know of. What RhinoScript needs is a way of accepting an array of points, not just one.

I take it your running all this from Excel?

– Dale

Dale, thanks a lot for Your reply!
Indeed - I was already searching for the possibility to use an array of points for the Rhino.SurfaceClosestPoint method but this seems not to be possible?!
And Yes, I’m running the whole application from Excel + VBA

Hi @B-Spline-Junkie,

Unfortunately, there isn’t anything we can do about the speed - sorry.

– Dale

Dale, thanks for your reply!
Somehow that’s what I’ve feared…

In the meantime I’ve done two things that helped a lot:

  • Instead of grabbing point per point I’m now using pointclouds
  • I’ve written an external routine in c which replaces the nearestpointonsurface method (this new function uses parallel computing and can handle many points in parallel)

The result is amazingly fast (for 100thousand points the CPU time is now reduced from minutes to some seconds)



1 Like