MeshCurveIntersection in RhinoCommon somehow? [Solved]

I’ve done some successful experiments using the GH component MeshCurveIntersection with the plan to implement the idea with RhinoCommon, but it seems that this functionality isn’t directly available in in RhinoCommon 5.

Is there any (other) command name that does the same thing?


// Rolf

Ah, I found it (I think):


// Rolf

MeshPolyline is slightly more useful if you’re dealing with curves. First convert your curve to a polyline using the required accuracy, then perform the intersection.

Thank you for the tips David. For now it suffice to use a straight line as a “probing ray” (I will convert the Face Normal which I already have, into a straight Line). Perhaps Line is also a bit faster but I don’t know that for sure yet.

// Rolf

It’s also faster. After some testing I found that MeshCurve is ~25% faster than MeshLine.

But how do I convert a Line to Curve in the simplest manner? I (re)use a Line in a loop by modifying the endpoints (based on Face Normals and their center points). Can the endpoints of a Curve also be modified or must a PolylineCurve always be created anew ?

// Rolf

new [LineCurve(line)](

Can the endpoints of a Curve also be modified or must a PolylineCurve always be created anew ?

If you use LineCurve, you can set the inner line: LineCurve.Line

Or you can access the NURBS curve control points: NurbsCurve.Points

For now it suffice to use a straight line as a “probing ray”

There is also Intersection.MeshRay I think that may be even faster then MeshCurve

Thank you, I will try this asap.

Update: Unfortunately the type LineCurve is not supported by Rhino.Geometry.Intersect.Intersection.MeshPolyline(...)

@menno, Using a “Ray” is a bit different since its extent, or length, isn’t limited. In my case I need full control of the length, or the far end of the curve, depending on the direction I probe. A ray will intersect with objects far away from the space I want to test. Otherwise MeshRay is an option as well, yes.

// Rolf

Since MeshRay returns the parameter on the ray for the first intersection, you can just ignore the hit if it exceeds your distance limit.

What does the parameter represent on a ray with unlimited extent?

The doc says:

Return Value
Type: Double
>= 0.0 parameter along ray if successful. < 0.0 if no intersection found. 

// Rolf

The parameter along the ray for the intersection point. I.e. the parameter you supply to the PointAt() method to get the point along the ray. It’ll be the start-point + parameter * direction-vector. So when t=0.0 it gives you the ray start point, t=1.0 gives you the point at the tip of the direction vector, t=2.0 gives you a point twice as far away again, etc. etc. It’s very much the same for finite and infinite lines.

1 Like

Ah thanks, I didn’t know that the ray has a vector length, nor that one could go beyond 1.0.

The text of your reply would be useful info to add to the documentation.

// Rolf