1 Reply Latest reply on Sep 6, 2017 11:15 AM by Alex Burnett

    Revision Table auto-populate

    Gary Liptrot


      I've been asked if its possible to write a macro to insert a revision table based on the sheet size (A4, A3, or A2), and populate the first line with the description "FIRST ISSUE"  I have three table templates that the user currently manually selects depending upon the sheet size.  They all snap to the upper-right table anchor and we use triangles as the revision symbol border but Revision A doesn't need a triangle.  The tables are populated top down in ascending order with the column title at the top:

      AFIRST ISSUE/date/initials


      Would it be too much to ask for someone to help me out in writing a simple macro that checks the sheet size, applies the appropriate template and inserts the table with the above text?



        • Re: Revision Table auto-populate
          Alex Burnett

          To start out, you would have to know the sheet size. This may help.

                  Set objActiveDoc = swApp.ActiveDoc 
                  Set swDraw = objActiveDoc
                  Set swSheet = swDraw.GetCurrentSheet
                  strDrawSize = swSheet.GetProperties(0)
                  Select Case strDrawSize
                      Case 0, 1
                          strDrawSize = "A"
                      Case 2
                          strDrawSize = "B"
                      Case 3
                          strDrawSize = "C"
                      Case 4
                          strDrawSize = "D"
                      Case 5
                          strDrawSize = "E"
                      Case 6, 7
                          strDrawSize = "A4"
                      Case 8
                          strDrawSize = "A3"
                      Case 9
                          strDrawSize = "A2"
                      Case 10
                          strDrawSize = "A1"
                      Case 11
                          strDrawSize = "A0"
                      Case 12
                          strDrawSize = "X"
                      Case Else
                          strDrawSize = "X"
                  End Select


          From there, you would have to select your template and apply it.

              Note, this code is from a separate c# program but it should translate okay with a bit of syntax change

                   swSheet.ReloadTemplate(false);  // false applies to the "keep note changes" flag


          Then you will add your revision table based on the page size as well

              Note, this is also code from a c# program. mCustomDrawingRevisionTable is my path to the table template file

                  swSheet.InsertRevisionTable2(true, 0, 0, (int)swBOMConfigurationAnchorType_e.swBOMConfigurationAnchor_TopRight,
                          mCustomDrawingRevisionTable, (int)swRevisionTableSymbolShape_e.swRevisionTable_HexagonSymbol, true);  // actually selects circle for bubble



          Finally, you can add your first row with the following command

                  // Get reference to the revision table that just got added
                  revTable = swSheet.RevisionTable;
                  // Get table object from revision table object
                  table = (TableAnnotation)revTable;  // may not be needed for your application 


          The data can be added with

                  table.Text[row, col] = "whatever you want in the cell";



          Hopefully this gets you on the right track with what you want to do.