AnsweredAssumed Answered

How to get the General Table width  with API?

Question asked by Yong Ning on May 15, 2014
Latest reply on May 16, 2014 by Patrick O'Hern

Manual can set the General table width,

000.jpg

 

API set General table width  → set columnwidth→ sum columnwidth.

 

Hope, how to get general table withdth with API

 

Sub ll1()

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

  Dim SwView As View, SwTable As TableAnnotation, SwAnn As Annotation

    Set SwApp = GetObject(, "SldWorks.Application")

    Set SwModel = SwApp.ActiveDoc

    Set SwDraw = SwModel

    Set SwView = SwDraw.GetFirstView

    Set SwTable = SwView.GetFirstTableAnnotation

    Dim X, Y, Z As Integer, Anch

    X = 25: Y = 5

    SwTable.AnchorType = 3

    Dim ColWidth As Double

    Dim SwFeat As Feature

    With SwTable        ''

        .Merge 0

        .Split 1, 13        ''

        For jj = 0 To .ColumnCount

          .SetColumnWidth jj, 0.02, 0

          ColWidth = ColWidth + .GetColumnWidth(jj)

        Next jj        ''

        For ii = 0 To .RowCount - 1

           .SetRowHeight ii, 0.005, 0

        Next ii

        .BorderLineWeight = 2

    End With 

    Do While Not SwTable Is Nothing   

       Set SwFeat = SwTable.GeneralTableFeature.GetFeature

       Debug.Print SwFeat.Name, SwTable.Title

       Set SwAnn = SwTable.GetAnnotation

       'Debug.Print SwTable.Title

       'ss = SwTable.GetAnnotation.GetPosition      

       SwAnn.SetPosition X / 1000, Y / 1000, 0

       'Stop

      Set SwTable = SwTable.GetNext

      X = X + ColWidth * 1000

    Loop       

End Sub

Attachments

Outcomes