2 Replies Latest reply on Jun 11, 2018 3:19 AM by Robert Voogt

    How do I change the font (family and size) of my BOM?

    Robert Voogt
              Set swBom = swBomAnn.GetAnnotation
              For i = 0 To swBom.GetTextFormatCount - 1
                  Set swTextFormat = swBom.GetTextFormat(i)
                  swTextFormat.CharHeight = 0.008
                  swTextFormat.Bold = False
                  swTextFormat.Italic = False
                  swTextFormat.TypeFaceName = "Calibri"
                  boolstatus = swBomTable.SetTextFormat(i, False, swTextFormat)


      Code runs without error, but it doesn't change the font. I assume I'm not assigning it correctly.


      I also tried

      boolstatus = swBomTable.SetColumnCustomProperty(i, swTextFormat)



      I was also thinking of changing the Font of tables under document property before inserting my BOM by using:

      boolstatus = swModel.Extension.SetUserPreferenceTextFormat(swUserPreferenceTextFormat_e.swDetailingTableTextFormat, swUserPreferenceOption_e.swDetailingNoOptionSpecified, <Value>)


      But I have no idea what to enter under <value>.

        • Re: How do I change the font (family and size) of my BOM?
          Manikandan Babu

          Hi Robert,


          Please refer the below code.


          Dim swApp As SldWorks.SldWorks

          Dim swmodel As SldWorks.ModelDoc2

          Dim swdraw As SldWorks.DrawingDoc

          Dim swview As SldWorks.View

          Dim vannotation As Variant

          Dim swtable As SldWorks.TableAnnotation

          Dim swTextFormat As SldWorks.Textformat

          Dim boolstatus As Boolean

          Dim swBOMAnnotation         As SldWorks.BomTableAnnotation

          Dim swBOMFeature            As SldWorks.BomFeature


          Sub main()

          Set swApp = Application.SldWorks

          Set swmodel = swApp.ActiveDoc

          Set swdraw = swmodel

          boolstatus = swdraw.ActivateView("Drawing View1")

          Set swview = swdraw.ActiveDrawingView

          Set swBOMAnnotation = swview.InsertBomTable2(False, 0.659923956199653, 0.526772700193777, swBOMConfigurationAnchorType_e.swBOMConfigurationAnchor_TopLeft, swBomType_e.swBomType_TopLevelOnly, "", "D\lang\english\bom-standard.sldbomtbt")

          Set swBOMFeature = swBOMAnnotation.BomFeature

          vannotation = swBOMFeature.GetTableAnnotations

          Set swtable = vannotation(0)

          Set swTextFormat = swtable.GetTextFormat

          swTextFormat.Underline = True

          swTextFormat.TypeFaceName = "Latha"

          boolstatus = swtable.SetTextFormat(False, swTextFormat)

          End Sub