Hide Table of Contents
IRayIntersections Method (IModelDoc2)

Intersects a given set of rays with a specified set of bodies.

.NET Syntax

Visual Basic (Declaration) 
Function IRayIntersections( _
   ByRef BodiesIn As Body2, _
   ByVal NumBodies As System.Integer, _
   ByRef BasePointsIn As System.Double, _
   ByRef VectorsIn As System.Double, _
   ByVal NumRays As System.Integer, _
   ByVal Options As System.Integer, _
   ByVal HitRadius As System.Double, _
   ByVal Offset As System.Double _
) As System.Integer
Visual Basic (Usage) 
Dim instance As IModelDoc2
Dim BodiesIn As Body2
Dim NumBodies As System.Integer
Dim BasePointsIn As System.Double
Dim VectorsIn As System.Double
Dim NumRays As System.Integer
Dim Options As System.Integer
Dim HitRadius As System.Double
Dim Offset As System.Double
Dim value As System.Integer
value = instance.IRayIntersections(BodiesIn, NumBodies, BasePointsIn, VectorsIn, NumRays, Options, HitRadius, Offset)
System.int IRayIntersections( 
   ref Body2 BodiesIn,
   System.int NumBodies,
   ref System.double BasePointsIn,
   ref System.double VectorsIn,
   System.int NumRays,
   System.int Options,
   System.double HitRadius,
   System.double Offset
System.int IRayIntersections( 
&   Body2^% BodiesIn,
&   System.int NumBodies,
&   System.double% BasePointsIn,
&   System.double% VectorsIn,
&   System.int NumRays,
&   System.int Options,
&   System.double HitRadius,
&   System.double Offset



Array bodies that are hit by the rays (see Remarks)


Number of bodies in the BodiesIn array


Array containing the x,y,z base points of each ray


Array containing the direction vectors of each ray


Number of rays specified; this should be equal to the number of elements in the (basePointsIn / 3) or (vectorsIn / 3) arrays


Number of options as defined in swRayPtsOpts_e


Radius of hit cylinder used mainly in grazing cases to establish a hit


Length tolerance to use to establish whether a hit on a face represents the entry or exit of the ray from the body (see Remarks)

Return Value

Number of intersections found


The method performs the intersection operations between the specified bodies and the ray vectors. To get the results (a set of intersection points, intersection normals, and the bodies that were hit from your bodiesIn array) of the intersection operations, you must call IModelDoc2::GetRayIntersectionsPoints or IModelDoc2::IGetRayIntersectionPoints and IModelDoc2::GetRayIntersectionTopology or IModelDoc2::IGetRayIntersectionsTopology.

Information returned by IModelDoc2::GetRayIntersectionsPoints, IModelDoc2::IGetRayIntersectionPoints, IModelDoc2::GetRayIntersectionTopology, and IModelDoc2::IGetRayIntersectionsTopology depends partially on the value of the options argument. Valid values can be concatenated together using bitwise operations. See IModelDoc2::GetRayIntersectionsPoints or IModelDoc2::IGetRayIntersectionPoints to see which data is always output regardless of the values specified in the options argument.

For the COM interface, the return value, the intersection count, must be used in determining the size of arrays to allocate for return values from IModelDoc2::IGetRayIntersectionsPoints and IModelDoc2::IGetRayIntersectionsTopology.


For each ray that hits an edge or a vertex, the offset distance is added in both the positive and negative directions along the ray and the points computed are tested for spatial inclusion in the hit body. This determines if the ray was entering, leaving, or just grazing the body at the hit point. Entry and exit onto faces can be computed does not require such an offset.


See Also


SOLIDWORKS 2001Plus FCS, Revision Number 10.0

Provide feedback on this topic

SOLIDWORKS welcomes your feedback concerning the presentation, accuracy, and thoroughness of the documentation. Use the form below to send your comments and suggestions about this topic directly to our documentation team. The documentation team cannot answer technical support questions. Click here for information about technical support.

* Required

Subject:   Feedback on Help Topics
Page:   IRayIntersections Method (IModelDoc2)
*   I acknowledge I have read and I hereby accept the privacy policy under which my Personal Data will be used by Dassault Systèmes

Print Topic

Select the scope of content to print:


We have detected you are using a browser version older than Internet Explorer 7. For optimized display, we suggest upgrading your browser to Internet Explorer 7 or newer.

 Never show this message again

Web Help Content Version: API Help (English only) 2016 SP05

To disable Web help from within SOLIDWORKS and use local help instead, click Help > Use SOLIDWORKS Web Help.

To report problems encountered with the Web help interface and search, contact your local support representative. To provide feedback on individual help topics, use the “Feedback on this topic” link on the individual topic page.