1 Reply Latest reply on Jan 9, 2018 5:01 PM by Alex Burnett

    Revision symbol's relation to row doesn't change when deleting rows from table.

    Alex Burnett

      Can anybody replicate this in SolidWorks releases past 2016 SP5?

       

      I'll preface this by saying this is a minor issue but I want to see if anyone is able to replicate what I am seeing with your data, templates. etc. I don't need a workaround or anything as that's already taken care of. I'm simply wondering if this is still an issue.

       

      My issue is that I have a bit of code written for a custom add-in to update the drawing template from an older one to a newer one. In this update, I read the data from the rows and columns of the old revision table and then I call GetRevisionSymbols(rowNumber) for each row of the table. This is then pasted into the new table and revision symbols are re-added according to their previously referenced row and position. A coworker had an issue when he deleted a row in the table AFTER assigning revision symbols to the rows that correspond with that revision. The macro was essentially offsetting everything after the deleted row and dropping of the last revision symbol altogether.

       

      I narrowed down the issue to this. The referenced row of a revision symbol does not change when a row is deleted above the affected rows in the table. In the example shown below, I ran my update before deleting a row and the output shows in the last column the revision bubble data as [tag: rowNumber     textInBubble]. I deleted the 2nd row and re-ran the update and the output shows that the last 2 rows moved up 1 row since data was deleted. GetRevisionSymbols(rowNumber) returns the wrong row for the data now and messes up the revision table. It essentially returns data as if the row were never removed.

       

      Normal Operation before deleting any rows:

      ZONE   REV. MAJOR REV. MINOR    ER         DESCRIPTION      BY      DATE          Revision Bubble Info

      A2     AA         01            5551100    UDPATE 1         AAA     1/5/2018      [tag: 2     01]

      B2     AA         02            5551100    UPDATE 2         AAA     1/5/2018      [tag: 3     02]

      B3     AA         03            5551100    UDPATE 3         AAA     1/5/2018      [tag: 4     03]

             AA         04            5551100    UPDATE 4         AAA     1/5/2018     

       

       

      Deleted Minor Rev AA-02:

      ZONE   REV. MAJOR REV. MINOR    ER           DESCRIPTION      BY     DATE          Revision Bubble Info

      A2     AA         01            5551100      UDPATE 1         AAA    1/5/2018      [tag: 2     01]

      B3     AA         03            5551100      UDPATE 3         AAA    1/5/2018     

             AA         04            5551100      UPDATE 4         AAA    1/5/2018      [tag: 4     03]    this rev bubble should be moved up 1 row

        • Re: Revision symbol's relation to row doesn't change when deleting rows from table.
          Alex Burnett

          Here's a code block that runs to give some output.

           

          Dim swApp As SldWorks.SldWorks
          Dim swModel As ModelDoc2
          Dim swFeature As Feature
          
          
          Dim swDraw As IDrawingDoc
          Dim swSheet As Sheet
          Dim swRevTable As RevisionTableAnnotation
          Dim swTable As TableAnnotation
          Dim swNote As INote
          
          
          Dim featureTypeName As String
          Dim tableContents As String
          
          
          
          
          
          
          
          
          Sub main()
              Set swApp = Application.SldWorks
              Set swModel = swApp.ActiveDoc
              
              If swModel.GetType = swDocumentTypes_e.swDocDRAWING Then
                  Set swDraw = swModel
                  Set swFeature = swModel.FirstFeature()
                  
                  While Not swFeature Is Nothing
                      featureTypeName = swFeature.GetTypeName()
                      
                      If featureTypeName = "DrSheet" Then
                          Set swSheet = swFeature.GetSpecificFeature2()
                          Set swRevTable = swSheet.RevisionTable
                          If Not swRevTable Is Nothing Then
                              Set swTable = swRevTable
                              tableContents = ""
                              For i = 0 To swTable.RowCount
                                  For j = 0 To swTable.ColumnCount
                                      tableContents = tableContents & vbTab & Replace(swTable.Text(i, j), vbCrLf, "")
                                  Next j
                                  
                                  If swRevTable.GetRevisionSymbolCount(i) Then
                                      Dim revSymbols As Variant
                                      revSymbols = swRevTable.GetRevisionSymbols(i)
                                      
                                      Set swNote = revSymbols(0)
                                      
                                      tableContents = tableContents & vbTab & "[Rev Symbol Row:(" & i & ") Contents:(" & swNote.PropertyLinkedText & ")]"
                                  End If
                                  tableContents = tableContents & vbCrLf
                              Next i
                              Debug.Print tableContents
                          End If
                      End If
                      
                      Set swFeature = swFeature.GetNextFeature()
                  Wend
              Else
                  MsgBox "File Type Error:  This is not a drawing file. Open a file with .slddrw extension and retry."
              End If
              
          
          
          End Sub
          

           

          Output: Before and After table images vs the API output

          Before:

           

          After:

           

          Before
              REVISIONS                           
              ZONE    REV.MAJOR   REV.MINOR   ER  DESCRIPTION BY  DATE    
              B2  AA  01  100001  UPDATE 1    AAA 1/9/2018        [Rev Symbol Row:(2) Contents:(01)]
              B1  AA  02  100002  UPDATE 2    AAA 1/9/2018        [Rev Symbol Row:(3) Contents:(02)]
              B1  AA  03  100003  UPDATE 3    AAA 1/9/2018        [Rev Symbol Row:(4) Contents:(03)]
              B1  AA  04  100004  UPDATE 4    AAA 1/9/2018        [Rev Symbol Row:(5) Contents:(04)]
                                          
          
          
          After
              REVISIONS                           
              ZONE    REV.MAJOR   REV.MINOR   ER  DESCRIPTION BY  DATE    
              B2  AA  01  100001  UPDATE 1    AAA 1/9/2018        [Rev Symbol Row:(2) Contents:(01)]
              B1  AA  03  100003  UPDATE 3    AAA 1/9/2018    
              B1  AA  04  100004  UPDATE 4    AAA 1/9/2018        [Rev Symbol Row:(4) Contents:(03)]
                                              [Rev Symbol Row:(5) Contents:(04)]