3 Replies Latest reply on Feb 3, 2013 6:12 PM by Artem Taturevych

    How to use Hole table with API?

    Yong Ning

      Hole tables in drawing documents measure the positions of selected holes from a specified origin datum. The software labels each hole with a tag that corresponds to a row in the table.



      At present, the manual methods  select hole .





      Hope select hole with API→Hole table.

      Thanks ever one.

        • Re: How to use Hole table with API?
          Artem Taturevych





          Artem Taturevych

          Application Engineer at Intercad


          Tel: +61 2 9454 4444

            • Re: How to use Hole table with API?
              Yong Ning

              Thank your tips


              In Solidworks 2011, run result is


              Dim spec As SldWorks.DocumentSpecification





              'Insert Hole Table Example (VBA)
              'This example shows how to insert a hole table into a drawing.
              ' Preconditions: Ensure that the model and template exist.
              ' Postconditions: A hole table is inserted in a drawing of the model.
              ' NOTE: Because the model is used elsewhere,
              ' do not save changes when closing it.
              ' ---------------------------------------------------------------------------
              Dim swApp As SldWorks.SldWorks
              Dim Part As SldWorks.ModelDoc2
              Dim spec As SldWorks.DocumentSpecification
              Dim Drawing As SldWorks.DrawingDoc
              Dim boolstatus As Boolean
              Option Explicit
              Sub main()
              Set swApp = Application.SldWorks
              Set spec = swApp.GetOpenDocSpec("install_dir\samples\handson\mate references\crank-arm.sldprt")
              Set Part = swApp.OpenDoc7(spec)
              Set Drawing = swApp.NewDocument("C:\ProgramData\SolidWorks\SolidWorks 2011\templates\Drawing.drwdot", 2, 0.2794, 0.4318)
              Set Part = Drawing
              boolstatus = Part.Extension.SelectByID2("Sheet1", "SHEET", 0.39237, 0.5218942019544, 0, False, 0, Nothing, 0)
              boolstatus = Part.Create3rdAngleViews2("install_dir\samples\handson\mate references\crank-arm.sldprt")
              Part.ClearSelection2 True
              boolstatus = Part.ActivateView("Drawing View2")
              'Select a vertex in the drawing view to be the origin of all datums in the table
              'All XLOC and YLOC table column values will be relative to this datum origin
              boolstatus = Part.Extension.SelectByID2("", "VERTEX", 0.05976280781759, 0.2143015374593, 0.003174999999999, False, 1, Nothing, 0)
              'Select a face that contains the holes that will be annotated in the table
              boolstatus = Part.Extension.SelectByID2("", "FACE", 0.1018457263844, 0.2224311921824, 0.003174999999999, True, 2, Nothing, 0)
              Dim myView As Object
              Set myView = Part.SelectionManager.GetSelectedObjectsDrawingView2(1, -1)
              Dim myHoleTable As Object
              'Insert a hole table
              'anchored with its top left corner at x-coordinate = 0.07m and y-coordinate = 0.175m,
              'with starting datum tag "A",
              'using hole table template: standard hole table--letters.sldholtbt
              Set myHoleTable = myView.InsertHoleTable2(False, 0.07841319218241, 0.1755661237785, swBOMConfigurationAnchorType_e.swBOMConfigurationAnchor_TopLeft, "A", "install_dir\lang\english\standard hole table--letters.sldholtbt")
              Part.ClearSelection2 True
              boolstatus = Part.ActivateSheet("Sheet1")

              End Sub