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))
Next
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 …
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
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)
My plugins often need more speed.
I imagine that a helper program running C language would work.
Any help I appreciate.
Is this method below faster?
import Rhino
import rhinoscriptsyntax as rs
point = rs.coerce3dpoint([41.015,-29.2098,88.1172])
super = rs.coercesurface(“148a73a8-bfd7-452d-a04b-18dbe8a17ff2”)
print Rhino.Geometry.Surface.ClosestPoint(super, point)