这个宏遍历featuremanager,solidworks需要先打开一个有feature树的文件:
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swFeature As SldWorks.feature
Dim FeatName As String
Dim FeatType As String
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
' If Not swApp Is Nothing Then
' If Not swModel Is Nothing Then
Set swFeature = swModel.FirstFeature
do While Not swFeature Is Nothing
FeatName = swFeature.Name
FeatType = swFeature.GetTypeName2
swFeature.Select2 False, 0
debug.print "Feature screen name = " & FeatName & vbCrLf & _
"Feature type name = " & FeatType
Set swFeature = swFeature.GetNextFeature
loop
' End If
Set swModel = Nothing
' End If
Set swApp = Nothing
End Sub