6 Replies Latest reply on May 15, 2014 7:36 AM by Deepak Gupta

    Placing a BOM on a drawing using a macro

    Carrie Ives

      I am trying to place a BOM onto a drawing using a macro. I have recorded the macro, but when I try to run it again it doesn't appear to do anything. I have tried recording it with the view selected before I start the recording, selecting the view during the recording, and just adding a BOM to the assembly instead. Can I do this?

       

      Here is what was recorded when I selected the drawing view.

       

      Dim swApp As Object

      Dim Part As Object
      Dim boolstatus As Boolean
      Dim longstatus As Long, longwarnings As Long

      Sub main()

      Set swApp = _
      Application.SldWorks

      Set Part = swApp.ActiveDoc
      Part.ClearSelection2 True
      Dim swActiveView As Object
      Set swActiveView = Part.ActiveDrawingView
      Dim swBOMTable As Object
      Set swBOMTable = swActiveView.InsertBomTable2(False, 0.7143060595691, 0.6169592264477, swBOMConfigurationAnchorType_e.swBOMConfigurationAnchor_TopLeft, swBomType_e.swBomType_Indented, "Default", "\\dalfs001\Common\Plano_Industrial_Design_Center\SolidWorks\Configuration\Tables\bom-standard.sldbomtbt")
      boolstatus = Part.EditRebuild3()
      boolstatus = Part.ActivateSheet("Sheet1")
      End Sub

       

      Thanks,

      Carrie