Files
Determine whether feature is suppressed
Code
'Written by Keith Rice
'CADSharp LLC
'keith@cadsharp.com
'SolidWorks API video tutorials will soon be available at www.cadsharp.com
'Response to https://forum.solidworks.com/message/229169
'Written with SolidWorks 2011
'Preconditions: part or assy is open with feature selected in the FM tree
'Postconditions: suppression state for that feature in the current config _
is stated in immediate window
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swSelMgr As SldWorks.SelectionMgr
Dim swFeat As SldWorks.Feature
Dim vConfigNames As Variant
Dim vSuppState As Variant
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
If Not swModel Is Nothing Then
Set swSelMgr = swModel.SelectionManager
'The first argument in ISelectionManager::GetSelectedObject6 _
indicates that only the first selected feature is looked at
vConfigNames = swModel.GetConfigurationNames
If swSelMgr.GetSelectedObjectType3(1, -1) = swSelectType_e.swSelBODYFEATURES Then
Set swFeat = swSelMgr.GetSelectedObject6(1, 0)
'The first argument in IFeature::IsSuppressed2 can be changed to _
return an array for all configurations
vSuppState = swFeat.IsSuppressed2(swThisConfiguration, vConfigNames)
'Only look at the first item in the index
If vSuppState(0) = True Then
Debug.Print "The feature is suppressed."
Else
Debug.Print "The feature is unsuppressed."
End If
Else
MsgBox "Select a feature."
End If
End If
End Sub
'Notes: IsSuppressed2 returns an array of booleans.