Hi All,
I’m trying to implement this Intersection.MeshRay overload through GHPython (i.e. that return the “faces on mesh that ray intersects”). I think I’ve got it working, but just wanted to check that I’m going about it properly. Calling the overload through IronPython seems a wee bit convoluted this way:
import Rhino as rc
from System import Array
import clr
def meshRayIntersect(mesh,point,vector):
""" Intersect a mesh with a ray, including intersected mesh face IDs """
ray = rc.Geometry.Ray3d(point,vector)
faceIDs = clr.StrongBox[Array[int]]()
rayP = rc.Geometry.Intersect.Intersection.MeshRay(mesh,ray,faceIDs)
if rayP >= 0.0:
rayPt = ray.PointAt(rayP)
faceIDs = list(faceIDs.Value)
return rayPt,faceIDs
else:
return None, None
XPt, XIDs = meshRayIntersect(MyMesh,MyPoint,MyVector)
That is, having to instantiate an Array
inside a StrongBox
prior to calling rc.Geometry.Intersect.Intersection.MeshRay
just to return the faceIDs. I might be way off here
Cheers,
Anders
Edit: Removed small bug, in case anyone implements the code directly.