4 Replies Latest reply on Jan 19, 2009 9:23 AM by Deepak Gupta

    Macro for General Table

    Deepak Gupta
      I have recorded one macro for inserting table. It is working perfect. But when I look at the codes, it doesn't show the path from where I have taken this table. Any hints on how to reveal the path so that I can modify it. I'm working on to create form in which user will input the required details and doesn't have to double click every cell of the table to fill in the information.

      TIA.
        • Macro for General Table
          Rob Jensen
          Deepak

          Below is the code i use to insert a general table. I'm not sure if it's waht your looking for or not.

          Set part = swApp.ActiveDoc
          Set SelMgr = part.SelectionManager
          swApp.ActiveDoc.ActiveView.FrameState = 1
          Dim genTable As Object
          Path = "j:\software\solidworks\tables\proto.sldtbt"
          Set genTable = part.InsertTableAnnotation2(True, 0, 0, swBOMConfigurationAnchorType_e.swBOMConfigurationAnchor_BottomLeft, Path, 3, 10)
          If Not genTable Is Nothing Then
          genTable.BorderLineWeight = 0
          genTable.GridLineWeight = 0
          • Macro for General Table
            Josh Brady
            Can you post the code?
            • Macro for General Table
              Deepak Gupta
              Thanks Rob for the codes but it doesn't take the specified General table template.

              Josh, here are the codes which I get on recording but that doesn't capture the path.

              *************************
              Dim swApp As Object
              Dim Part As Object
              Dim SelMgr As Object
              Dim boolstatus As Boolean
              Dim longstatus As Long, longwarnings As Long
              Dim Feature As Object
              Sub main()

              Set swApp = Application.SldWorks

              Set Part = swApp.ActiveDoc
              Set SelMgr = Part.SelectionManager
              Dim genTable As Object
              Set genTable = Part.InsertTableAnnotation(0.01664901006679, 0.540689663236, 1, 4, 3)
              If Not genTable Is Nothing Then
              genTable.BorderLineWeight = 1
              genTable.GridLineWeight = 0
              End If
              Part.ClearSelection2 True
              End Sub
              • Macro for General Table
                Deepak Gupta
                After some modification given in API help example, I have made my macro to read the template specified in the code. Now next step is to develop a window in which user will fill the data and it will populate into the table. Here are the codes:
                '************'
                Option Explicit

                Public Enum swBOMConfigurationAnchorType_e

                swBOMConfigurationAnchor_TopLeft = 1

                swBOMConfigurationAnchor_TopRight = 2

                swBOMConfigurationAnchor_BottomLeft = 3

                swBOMConfigurationAnchor_BottomRight = 4

                End Enum

                Sub main()

                Dim swApp As SldWorks.SldWorks

                Dim swModel As SldWorks.ModelDoc2

                Dim swSelMgr As SldWorks.SelectionMgr

                Dim swDraw As SldWorks.DrawingDoc

                Dim swTable As SldWorks.TableAnnotation

                Dim bRet As Boolean

                Dim vPickPt As Variant




                Set swApp = Application.SldWorks

                Set swModel = swApp.ActiveDoc

                Set swDraw = swModel

                Set swSelMgr = swModel.SelectionManager

                vPickPt = swSelMgr.GetSelectionPoint(1)

                'Change you General table template name and path here. Also set you Achor type'

                Set swTable = swDraw.InsertTableAnnotation2(True, vPickPt(0), vPickPt(1), 4, "D:\4X3.sldtbt", 4, 3)


                If Not swTable Is Nothing Then
                swTable.BorderLineWeight = 2
                swTable.GridLineWeight = 1
                End If
                End Sub