Files
Select edges in drawing view
Code
'Demonstrates how to select visible entities in a drawing view
'Written by Keith Rice
'CADSharp LLC
'www.cadsharp.com
'Preconditions: Drawing is open and drawing view is selected
'Postconditions: All visible edges in visible components in that view are selected
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swModelDocExt As SldWorks.ModelDocExtension
Dim swSelMgr As SldWorks.SelectionMgr
Dim swComp As SldWorks.Component2
Dim swView As SldWorks.View
Dim swEnt As SldWorks.Entity
Dim vComps As Variant
Dim vEdges As Variant
Dim i As Integer
Dim j As Integer
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swModelDocExt = swModel.Extension
Set swSelMgr = swModel.SelectionManager
Set swView = swSelMgr.GetSelectedObject6(1, -1)
swModel.ClearSelection2 True
'Get all visible components
vComps = swView.GetVisibleComponents
For i = 0 To UBound(vComps)
'Get all edges on the first visible component
vEdges = swView.GetVisibleEntities(vComps(i), swViewEntityType_Edge)
'Iterate through and select all edges on the first visible component
For j = 0 To UBound(vEdges)
Set swEnt = vEdges(j)
swView.SelectEntity swEnt, True
Next j
Next i
End Sub