Quantcast
Channel: Rhino Developer - McNeel Forum
Viewing all articles
Browse latest Browse all 8557

Intersection.MeshRay with meshFaceIndices Overload using GHPython

$
0
0

@AndersDeleuran wrote:

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:
        rayPt = ray.PointAt(rayP)
        faceIDs = list(faceIDs.Value)
        return rayPt,faceIDs
    else:
        return 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 :man_shrugging:

Cheers,

Anders

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 8557

Trending Articles