Traverse Feature By Reverse Position Example (VBA)
This example shows how to traverse backwards
through the list of features. It obtains features by their position using
IModelDoc2::FeatureByPositionReverse.
'---------------------------------------------
Dim swApp As Object
Dim Part As Object
Dim theFeature As Object
Dim featCount As Long
Dim featName As String
Sub main()
Set swApp = CreateObject
("SldWorks.Application")
Set Part = swApp.ActiveDoc
featCount =
Part.GetFeatureCount
swApp.SendMsgToUser "Feature Count =
" + Str(featCount)
For i = featCount
to 1 step -1
Set theFeature
= Part.FeatureByPositionReverse(featCount-i)
featName
= theFeature.Name
Set theFeature
= Nothing
swApp.SendMsgToUser "Feature " +
Str(i) + " is " + featName
Next
Set Part = Nothing
End Sub