3 Replies Latest reply on Aug 16, 2017 2:41 AM by Duncan Gillis

    Delete all Rows and add new in Revision table

    Deepak Gupta

      Can anybody share codes or create a macro that will delete all rows from the revision table on a active drawing file and finally add new row to it with specified values.

       

      Thanks for the help.

        • Re: Delete all Rows and add new in Revision table
          Artem Taturevych

          Hi Deepak,

           

          Here is the macro. Please let me know if any questions.

           

          Dim swApp As SldWorks.SldWorks

          Dim swDraw As SldWorks.DrawingDoc

          Dim swSheet As SldWorks.Sheet

          Dim swRevTable As SldWorks.RevisionTableAnnotation

          Dim swTableAnn As SldWorks.TableAnnotation

           

           

          Dim REVISION_DATA_TO_ADD As Variant 'values for columns in new revision

           

           

          Sub main()

           

           

              'use empty string to skip the column

              REVISION_DATA_TO_ADD = Array("Zone1", "", "Test Description", "", "AppByEng")

             

              Set swApp = Application.SldWorks

           

           

              Set swDraw = swApp.ActiveDoc

             

              Set swSheet = swDraw.GetCurrentSheet

             

              Set swRevTable = swSheet.RevisionTable

             

              If Not swRevTable Is Nothing Then

                 

                  Set swTableAnn = swRevTable

                 

                  Dim i As Integer

                 

                  For i = swTableAnn.RowCount - 1 To 0 Step -1

                     

                      Dim revId As Long

                      revId = swRevTable.GetIdForRowNumber(i)

                     

                      If revId <> 0 Then

                          swRevTable.DeleteRevision revId, True

                      End If

                     

                  Next

                 

                  swRevTable.AddRevision "NewA"

                 

                  For i = 0 To UBound(REVISION_DATA_TO_ADD)

                     

                      If REVISION_DATA_TO_ADD(i) <> "" Then

                          swTableAnn.Text(swTableAnn.RowCount - 1, i) = REVISION_DATA_TO_ADD(i)

                      End If

                     

                  Next

                 

              End If

             

          End Sub

           

          ____________________________________________________

          Regards,

          Artem Taturevych, Application Engineer at Intercad (Australia)

           

          translationXpert – add-in to translate SolidWorks models

          LinkedIn SolidWorks API Education Group