Show Hidden Edges Example (VBA)
This example shows how to show the hidden edges.
'---------------------------------------------------
'
' Preconditions:
' (1)
Drawing document is open that has
' contains
a model with hidden edges.
' (2)
The programmatically selected face contains
' one
or more hidden edges.
'
' Postconditions: All hidden edges on the selected face
are now visible.
'
' NOTE: This macro will work even if the selected face
' does
not have any hidden edges.
'
'----------------------------------------------------
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swDrawingDoc As SldWorks.DrawingDoc
Dim swModel As SldWorks.ModelDoc2
Dim swSelMgr As SldWorks.SelectionMgr
Dim swModelDocExt As SldWorks.ModelDocExtension
Dim swFace As SldWorks.Face2
Dim swSelData As SldWorks.SelectData
Dim vEdges As Variant
Dim NbrOfEdges As Long
Dim boolstatus As Boolean
Dim i As Long
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swDrawingDoc = swModel
Set swSelMgr = swModel.SelectionManager
Set swModelDocExt = swModel.Extension
Set swSelData = swSelMgr.CreateSelectData
' Activate a drawing view
boolstatus = swDrawingDoc.ActivateView("Drawing
View2")
' Select a face in the activated view that has hidden
edges
boolstatus = swModelDocExt.SelectByID2("",
"FACE", 0.2262086319035, 0.109004199964, -499.8803646186, False,
1, Nothing, 0)
Set swFace = swSelMgr.GetSelectedObject6(1,
1)
' Get the number of edges on the selected face
NbrOfEdges = swFace.GetEdgeCount
Debug.Print "Number of edges on this face: "
& NbrOfEdges
' Get the edges on the selected face
vEdges = swFace.GetEdges
' Show each edge on the face
For i = 0 To (NbrOfEdges - 1)
boolstatus
= vEdges(i).Select4(True, swSelData)
'Show
the edge
swDrawingDoc.ShowEdge
Next i
End Sub