Hi All,
I have some questions regarding to SelectByID2 and SelectByRay method, let say I have a model and want to select an edge highlighted in the picture below:
Below is the sample code I used to do the selection:
Option Explicit
Dim swApp As SldWorks.SldWorks
Sub main()
Set swApp = Application.SldWorks
Dim swModel As ModelDoc2
Set swModel = swApp.ActiveDoc
Dim bRet As Boolean
' SelectByID2 method
bRet = swModel.Extension.SelectByID2("", "EDGE", 0.15, -0.15, -0.05, False, 0, Nothing, 0)
Debug.Print bRet
' Obsolete SelectByRay method
Dim DoubleInfo(6) As Double
DoubleInfo(0) = 0
DoubleInfo(1) = 0
DoubleInfo(2) = 0
DoubleInfo(3) = 1
DoubleInfo(4) = 0
DoubleInfo(5) = 0
DoubleInfo(6) = 0.01
bRet = swModel.SelectByRay(DoubleInfo, swSelectType_e.swSelEDGES)
Debug.Print bRet
' SelectByRay method
bRet = swModel.Extension.SelectByRay(DoubleInfo(0), DoubleInfo(1), DoubleInfo(2), DoubleInfo(3), DoubleInfo(4), DoubleInfo(5), DoubleInfo(6), swSelectType_e.swSelEDGES, False, 0, 0)
Debug.Print bRet
End SubIf the edge is in hidden behind another geometry, SelectByID2 method will fail.
While both SelectByRay return true, but it is not the edge which I imagine it will choose. Post below describes the same issue that I am having, it is solved by using the obsolete method but only work on selecting face:
The SelectByID2 method will only return true when the model is oriented where the edge is visible.
May I know how to properly use the SelectByRay method to select edge? Attached is the sample model:
