Select Tangent Edges Topologically Example (VBA)
This example shows how to selected edges using IEdges::GetTangentEdges,
which is a topological function and, therefore, precise.
'--------------------------------------------
Option Explicit
Sub main()
Dim
swApp As
SldWorks.SldWorks
Dim
swModel As
SldWorks.ModelDoc2
Dim
swSelMgr As
SldWorks.SelectionMgr
Dim
swSelEdge As
SldWorks.Edge
Dim
vTanEdgeArr As
Variant
Dim
vTanEdge As
Variant
Dim
swTanEdge As
SldWorks.Edge
Dim
swTanEnt As
SldWorks.entity
Dim
bRet As
Boolean
Set
swApp = Application.SldWorks
Set
swModel = swApp.ActiveDoc
Set
swSelMgr = swModel.SelectionManager
Set
swSelEdge = swSelMgr.GetSelectedObject5(1)
'
IEdge::GetTangentEdges does not give same results as user
'
interface select tangency method, IModelDoc2::SelectTangency,
'
because the user interface functionality automatically takes
'
into account edges that lie on top of each other and is, therefore, imprecise.
'
IEdge::GetTangentEdges is a topological function and is precise.
vTanEdgeArr
= swSelEdge.GetTangentEdges: If
IsEmpty(vTanEdgeArr) Then Exit Sub
For
Each vTanEdge In vTanEdgeArr
Set
swTanEdge = vTanEdge
Set
swTanEnt = swTanEdge
bRet
= swTanEnt.Select4(True, Nothing):
Debug.Assert bRet
Next
vTanEdge
End Sub
'--------------------------------------------