AnsweredAssumed Answered

VBA - Delete BOM Macro - Question

Question asked by Cad Admin on May 31, 2017
Latest reply on Jun 1, 2017 by Cad Admin

I use a simple macro i found here in the forum. https://forum.solidworks.com/message/706196#comment-706196 from Artem Taturevych . I have a Drawing with 7 different BOMS in the tree, i needed them to all be deleted.  I believed this used to work, but for some reason it is only deleting one BOM now.  From what i know it should continue till the swFeat = nothing, aka end of the feature tree.

 

Sub Main()

 

    Dim swApp           As SldWorks.SldWorks

    Dim swModel         As SldWorks.ModelDoc2

    Dim swFeat          As SldWorks.Feature

 

    Set swApp = Application.SldWorks

    Set swModel = swApp.ActiveDoc

    Set swFeat = swModel.FirstFeature

   

    While Not swFeat Is Nothing

   

        If "BomFeat" = swFeat.GetTypeName Then

            swFeat.Select2 False, -1

            swModel.Extension.DeleteSelection2 swDeleteSelectionOptions_e.swDelete_Absorbed

        End If

 

        Set swFeat = swFeat.GetNextFeature

 

    Wend

   

End Sub

 

Outcomes