2 Replies Latest reply on May 15, 2014 12:31 AM by Yong Ning

    How to move the general table position with API?

    Yong Ning

      00.jpg

      0.jpg

        • Re: How to move the general table position with API?
          Keith Rice

          Hi,

           

          Please replace the coordinates in IAnnotation::SetPosition below to your desired coordinates.

           

          ======

           

          Dim swApp As SldWorks.SldWorks

          Dim swModel As SldWorks.ModelDoc2

          Dim swSelMgr As SldWorks.SelectionMgr

          Dim swTable As SldWorks.TableAnnotation

          Dim swAnn As SldWorks.Annotation

           

          Sub main()

              Set swApp = Application.SldWorks

              Set swModel = swApp.ActiveDoc

              Set swSelMgr = swModel.SelectionManager

              Set swTable = swSelMgr.GetSelectedObject6(1, -1)

              Set swAnn = swTable.GetAnnotation

              swAnn.SetPosition 0, 0, 0

          End Sub

           

          ======

           

          Keith

          SolidWorks API Tutorials

            • Re: How to move the general table position with API?
              Yong Ning

              Thank your method→ Set swAnn = swTable.GetAnnotation

               

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

              Sub ll()

                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

                  With SwTable

                      For jj = 0 To .ColumnCount

                        .SetColumnWidth jj, 0.01, 0

                        ColWidth = ColWidth + .GetColumnWidth(jj)

                      Next jj

                      Debug.Print ColWidth

                      Stop

                      For ii = 0 To .RowCount - 1

                         .SetRowHeight ii, 0.005, 0

                      Next ii

                      .BorderLineWeight = 2

                     

                  End With

                 

                  xx = 0

                  Do While Not SwTable Is Nothing

                     Set SwAnn = SwTable.GetAnnotation

                     'Debug.Print SwTable.Title

                     ss = SwTable.GetAnnotation.GetPosition

                     Debug.Print Round(ss(0), 3), Round(ss(1), 3)

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

                     'Stop

                    Set SwTable = SwTable.GetNext

                    X = X + 20

                  Loop

                 

                 

              End Sub