Project Point on to Surface with chosen Vector (Not C-Plane)

Hello all,

I am very new to Rhino so please forgive the following stupidity. I’ll reduce my problem to one very simple manoeuvre. Or what should be simple.
I need to project a point, lying outside a sphere onto the surface of the sphere but with the centre of the sphere as the point of direction. In other words the point heads for the centre of the sphere but stops on the surface.
There does not seem to a command for this. There are similar commands but not quite the same.
There is rhinoscript …ProjectPointtoSurface which goes as follows…

Sub TestProjectPoints
Dim arrObjects, strSurface

strSurface = Rhino.GetObject(“Select surface to project onto”, 8)

arrObjects = Rhino.GetObjects(“Select points to project”, 1)

Dim nBound, arrPoints

nBound = UBound(arrObjects)

ReDim arrPoints( nBound )

Dim i

For i = 0 To nBound

arrPoints(i) = Rhino.PointCoordinates( arrObjects(i) )


’ Project down…

Dim arrResults

arrResults = Rhino.ProjectPointToSurface(arrPoints, strSurface, Array(0,0,-1))

Rhino.AddPoints arrResults

End Sub

This is close but I’m guessing its using the c-plane as the ‘vector’ (?). I have tried rewriting the code so that I can choose a point or vector of direction but to no avail. I wont publish my rewrites for they may disturb (or depress) you. I’ll keep trying to get the code right but at the same time I feel like I must be missing something incredibly simple that does not require script.

I dont need to project vast or complex arrays. I’m happy to go point by point. If anyone has a simple solution for this I’d be very grateful.


Is your use case always with a point and a sphere? IF so you could use closest point.
Geometrically the closest point on a sphere is always the intersection of a line (between the sphere center and your test point ) and your sphere.

You also have an option to provide the direction (maybe projDir I am not at the computer and can’t remember the detail) of projection and the direction will be the selection of two points: point you want to project and the OSnap point CENTER of the Sphere!

Thank you Lando. I think that will actually do that trick for now. I knew I was over complicating things.

I downloaded the ProjectDir script from wiki.mcneel and having a look at it now. Its slightly odd in that it asks me for two directions but I’m sure its the way to go with large arrays of points. (when I figure it out!)

Thanks both for really helpful replies.