4 Replies Latest reply on Dec 6, 2017 12:59 AM by Deepak Gupta

    Show overridden BOM cells?

    Tom Gagnon

      Is there any way to display which cells are overridden in a BOM? I'd like to un-override them, restoring them to default parametric values.


      I filled in information to a BOM as overrides while a teammate had read rights on the components. Now I'd like to identify which ones they were (a couple handfuls out of 483 components) so that I can un-override the cells, and properly edit the information back to the components for future use. Current installation Ref: 2016 SP5.


      The only similar thread that I found was https://forum.solidworks.com/message/22167, which remained unanswered.


      Ideally, I'd like ability to toggle a visual indication such as a background highlight color, or different text color.

      If this differentiation doesn't exist, I'd settle for a command to restore all overrides to default values.

      If none of this exists, I'd like to suggest it as an idea for improvement.


      Thank you.

        • Re: Show overridden BOM cells?
          Deepak Gupta

          Not sure when it was added but if you click on any cell in the BOM table, the overwritten cells should highlight.


          • Re: Show overridden BOM cells?
            Elmar Klammer

            Hi Tom,


            Try this


            ' Preconditions: Drawing must be open.
            ' Postconditions: None

            Option Explicit

            Dim brokenLinkValue As Boolean

            Sub ProcessTable(swApp As SldWorks.SldWorks, swModel As SldWorks.ModelDoc2, swTable As SldWorks.TableAnnotation)
                Dim swAnn                   As SldWorks.Annotation
                Dim nNumCol                 As Long
                Dim nNumRow                 As Long
                Dim sRowStr                 As String
                Dim i                       As Long
                Dim j                       As Long

                Set swAnn = swTable.GetAnnotation
                nNumCol = swTable.ColumnCount
                nNumRow = swTable.RowCount

                ' Show the name and type of table
                Debug.Print "    " & swAnn.GetName & " <" & swTable.Type & ">"

                ' Get the table contents
                For i = 0 To nNumRow - 1

                    sRowStr = "      ["

                    For j = 0 To nNumCol - 1
                        sRowStr = sRowStr & swTable.Text(i, j) & ","
                        'Is it a broken cell link?
                        Dim oldValue As String
                        oldValue = swTable.Text(i, j)
                        swTable.Text(i, j) = ""
                        Dim newValue As String
                        newValue = swTable.Text(i, j)
                        If Not (newValue = "") Then
                            'This is a linked cell
                            If Not (Trim(newValue) = Trim(oldValue)) Then
                                'linked value was restored when cell text was cleared
                                brokenLinkValue = True
                            End If
                        End If
                        'In either case restore the old value
                        swTable.Text(i, j) = oldValue
                        If (brokenLinkValue = True) Then
                            Debug.Print "Cell (" & i & " ," & j & ")" & " Text is a broken link value - with link value of " & newValue
                            brokenLinkValue = False
                        End If
                    Next j
                    ' Show the table contents
                    Debug.Print Left(sRowStr, Len(sRowStr) - 1) & "]"
                Next i

            End Sub

            Sub main()

                Dim swApp                   As SldWorks.SldWorks
                Dim swModel                 As SldWorks.ModelDoc2
                Dim swDraw                  As SldWorks.DrawingDoc
                Dim swView                  As SldWorks.View
                Dim swTable                 As SldWorks.TableAnnotation
                Dim bRet                    As Boolean
                Set swApp = Application.SldWorks
                Set swModel = swApp.ActiveDoc
                Set swDraw = swModel
                brokenLinkValue = False

                Debug.Print "File = " & swModel.GetPathName

                ' Get the first view
                Set swView = swDraw.GetFirstView

                Do While Not swView Is Nothing
                    ' Show the name of the view
                    Debug.Print "  " & swView.Name
                    ' Get the first table annotation for this view
                    Set swTable = swView.GetFirstTableAnnotation

                    Do While Not swTable Is Nothing

                        ProcessTable swApp, swModel, swTable
                        ' Get next table annotation for this view
                        Set swTable = swTable.GetNext


                    ' Get the next view
                    Set swView = swView.GetNextView


            End Sub