MACRO LIBRARY

Delete BOM table from part

Free public access. No account or subscription required.

Files

Delete BOM table from part

Code

'Deletes a single BOM table from a part
    
'Preconditions: part containing BOM table is open
    
'Written by Keith Rice
'CADSharp LLC
'www.cadsharp.com
    
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swFeat As SldWorks.Feature
Dim swSubFeat As SldWorks.Feature
Dim swBomFeat As SldWorks.BomFeature
Dim vBOMTableAnns As Variant
Dim swBomTableAnn As SldWorks.BomTableAnnotation
Dim swTableAnn As SldWorks.TableAnnotation
Dim swAnn As SldWorks.Annotation
    
Sub main()
    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc
    Set swFeat = swModel.FirstFeature
    Do While Not swFeat Is Nothing
        If swFeat.GetTypeName2 = "TableFolder" Then
            Set swSubFeat = swFeat.GetFirstSubFeature
            Set swBomFeat = swSubFeat.GetSpecificFeature2
            vBOMTableAnns = swBomFeat.GetTableAnnotations
            Set swBomTableAnn = vBOMTableAnns(0)    'assume only one BOM table
            Set swTableAnn = swBomTableAnn
            Set swAnn = swTableAnn.GetAnnotation
            swAnn.Select3 False, Nothing
            swModel.EditDelete
            Exit Do
        End If
        Set swFeat = swFeat.GetNextFeature
    Loop
End Sub