Activate Feature Example (VBA)
This example shows how to show the dimensions of the selected feature
by activating the feature.
'---------------------------------------------
'
' Preconditions: Feature for which you want to show
' its
dimensions is selected.
'
' Postconditions: Features's dimensions are displayed
' in
the graphics area.
'
'---------------------------------------------
Option Explicit
Sub main()
Dim
swApp As
SldWorks.SldWorks
Dim
swModel As
SldWorks.ModelDoc2
Dim
swSelMgr As
SldWorks.SelectionMgr
Dim
swFeat As
SldWorks.feature
Set
swApp = Application.SldWorks
Set
swModel = swApp.ActiveDoc
Set
swSelMgr = swModel.SelectionManager
Set
swFeat = swSelMgr.GetSelectedObject5(1)
swModel.ActivateSelectedFeature
Debug.Print
"File = " & swModel.GetPathName
Debug.Print
" Feature
=
" + swFeat.Name + "
[" + swFeat.GetTypeName +
"]"
End Sub
'---------------------------------------------