VBA宏以隐藏SOLIDWORKS文件树中的所有选定特征
这个VBA宏允许在树中使选定的特征不可见。这些特征仍然可以在图形区域中完全操作和显示(例如平面),但在特征管理器树中不可见。
甚至可以使默认特征(如平面)不可见。
要显示隐藏的特征,请使用显示隐藏的特征宏。
Dim swApp As SldWorks.SldWorks
Sub main()
Set swApp = Application.SldWorks
Dim swModel As SldWorks.ModelDoc2
Set swModel = swApp.ActiveDoc
If Not swModel Is Nothing Then
Dim swSelMgr As SldWorks.SelectionMgr
Set swSelMgr = swModel.SelectionManager
Dim i As Integer
For i = 1 To swSelMgr.GetSelectedObjectCount2(-1)
Dim swFeat As SldWorks.Feature
Set swFeat = swSelMgr.GetSelectedObject6(i, -1)
swFeat.SetUIState swUIStates_e.swIsHiddenInFeatureMgr, True
Next
swModel.EditRebuild3
Else
MsgBox "请打开模型"
End If
End Sub