ProjectPointsToMeshes

Hi,

I’m currently using ProjectPointsToMeshes with a List of Points. I project the points to the mesh, to see which ones are within the x,y bounds of the mesh - but I actually want to keep the Z value of the original points. Currently in order to achieve this I am iterating through the outpoints and for each point in outpoints I am iterating through the inpoints to find the corresponding inpoint (by x,y) and then storing this inpoint to a filtered list.

This is verrry slooow. Is there a different command that I could use to achieve the same effect? In other words - I want something that behaves more like cookie cutter.

I note that an older version of ProjectPointstoBreps had an out parameter of Indices - which would have been ideal - but this no longer seems to be available.

Thanks,

Hannah

Hi Hannah,

Intersection.MeshRay method requires a single element (point), not a list of elements, which could be useful to set up a conditional by which you could extract the hit points (those that can be projected to a mesh). All of this in a single loop.

I can see you are using C#, but can’t help you with it. This is a python example:

import Rhino

# pts = list of points to check for projection
dir = Rhino.Geometry.Vector3d(0,0,-1)

hitPts = []
for pt in pts:
    ray = Rhino.Geometry.Ray3d(pt, dir)
    lineLength = Rhino.Geometry.Intersect.Intersection.MeshRay(m,ray)
    if lineLength >= 0:    # less than 0 -> no intersection
        hitPts.append(pt)    # or hitPts.append(pt.Z)

Ah - Nice one. Thank you. That looks like it will be very useful.

The Rhino SDK contains a function that will project points onto a mesh and return both the projected points and a map that identifies which input point matches the projected (output) point. I can see how this would be valuable to you. I’ll see about getting this exposed in a future service release.

Oh - that would be fab. Thank you!

A PtojectPointsToMeshesEx function which provides output indices will be available in SR10

Thank you.