1 Reply Latest reply on Jan 21, 2015 10:23 AM by Keith Rice

    How to get  quantity in Hole Table?

    Yong Ning

      00.jpg

       

       

       

      Follow code can get TableAnnotations

      Hope get quantity . see picture?

      **************************************

      Private Sub del20150121()

         Dim SwApp As SldWorks.SldWorks, SwModel As ModelDoc2, SwDraw As DrawingDoc

            Set SwApp = Application.SldWorks

            Set SwModel = SwApp.ActiveDoc

            Set SwDraw = SwModel

         Dim SwFeat As Feature

            Set SwFeat = SwDraw.FeatureByName("HTable")

       

       

         Dim hTable As HoleTable, SwTabAnn As TableAnnotation

            Set hTable = SwFeat.GetSpecificFeature2

            Stop

            With hTable

               Debug.Print .GetTableAnnotationCount

               Set SwTabAnn = .GetTableAnnotations(0)

      '''' How to get quantity in Hole Table?

            End With

            Stop

      End Sub

        • Re: How to get  quantity in Hole Table?
          Keith Rice

          Yong,

           

          Simply traverse all cells in the hole table until you find the one with text equal to "Quantity", then get the cell directly below it.

           

              For intCol = 0 To SwTabAnn.ColumnCount - 1
                  For intRow = 0 To SwTabAnn.RowCount - 1
                      If SwTabAnn.Text(intRow, intCol) = "QUANTITY" Then
                          Debug.Print SwTabAnn.Text(intRow + 1, intCol)
                      End if
                  Next intRow
              Next intCol
          

           

          You might also add "Option Compare Text" at the top of your code so that text comparison is always case-insensitive.

           

          Keith

          SolidWorks API Training