Get Sketch Point's View Example (VBA)
This example shows how to get the view for the selected sketch point.
'-----------------------------------------------
'
' Preconditions:
' (1)
Drawing document is open.
' (2)
Sketch point in any of the views is selected.
'
' Postconditions: None
'
'-----------------------------------------------
Option Explicit
Sub main()
Dim
swApp As
SldWorks.SldWorks
Dim
swModel As
SldWorks.ModelDoc2
Dim
swSelMgr As
SldWorks.SelectionMgr
Dim
swSkPt As
SldWorks.SketchPoint
Dim
swSketch As
SldWorks.sketch
Dim
swSketchFeat As
SldWorks.feature
Dim
swDraw As
SldWorks.DrawingDoc
Dim
swView As
SldWorks.View
Dim
swViewSketch As
SldWorks.sketch
Dim
bRet As
Boolean
Set
swApp = Application.SldWorks
Set
swModel = swApp.ActiveDoc
Set
swDraw = swModel
Set
swSelMgr = swModel.SelectionManager
Set
swSkPt = swSelMgr.GetSelectedObject5(1)
Set
swSketch = swSkPt.GetSketch
Set
swSketchFeat = swSketch
Debug.Print
"File = " & swModel.GetPathName
Debug.Print
" "
& swSketchFeat.Name
Set
swView = swDraw.GetFirstView
Do
While Not Nothing Is swView
Set
swViewSketch = swView.GetSketch
If
swSketch Is swViewSketch Then
Debug.Print
" --
> " & swView.Name
Exit
Do
End
If
Set
swView = swView.GetNextView
Loop
End Sub
'-----------------------------------------------