MACRO LIBRARY

Get the edges attached to a vertex

Free public access. No account or subscription required.

Files

Get the edges attached to a vertex

Code

'Precondition: Vertex is selected
'Postcondition: Edges attached to vertex are selected
    
'Written by Keith Rice
'CADSharp LLC
'www.cadsharp.com
    
Option Explicit
    
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swSelMgr As SldWorks.SelectionMgr
Dim swVert As SldWorks.Vertex
Dim vEdgeArr As Variant
Dim vEdge As Variant
Dim swEdge As SldWorks.Edge
Dim swEnt As SldWorks.Entity
Dim bRet As Boolean
    
Sub main()
    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc
    Set swSelMgr = swModel.SelectionManager
    Set swVert = swSelMgr.GetSelectedObject5(1)
    swModel.ClearSelection2 True
    
    vEdgeArr = swVert.GetEdges
    For Each vEdge In vEdgeArr
        Set swEdge = vEdge
        Set swEnt = swEdge
        
        bRet = swEnt.Select4(True, Nothing)
    Next vEdge
End Sub