Files
Select a face using IModelDoc2::SelectByRay Associated model(s)
Code
'Demonstrates IModelDoc2::SelectByRay
'Preconditions: selectbyray.SLDPRT is open (or any other body that covers the origin)
'Results: face is selected
'Written by Keith Rice
'CADSharp LLC
'www.cadsharp.com
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim dblParams(6) As Double
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
'start point of ray
dblParams(0) = 0
dblParams(1) = 0
dblParams(2) = 0.1
'direction of ray
dblParams(3) = 0
dblParams(4) = 0
dblParams(5) = -1 'negative z direction
'radius of cylinder
dblParams(6) = 1 'arbitrary value; ignored if selecting faces
'Only IEntity objects are accepted (vertices, edges, co-edges, loops, faces)
Debug.Print swModel.SelectByRay(dblParams, swSelectType_e.swSelFACES)
End Sub