How to get quantity in Hole Table?

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

SolidworksApi macros
Answers 1
KR
KR 2015-01-21 Best Answer

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.

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

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