Hide Table of Contents

Insert Punch Table Example (VB.NET)

This example shows how to insert a punch table in the flat pattern view of a sheet metal part that contains one or more forming tool features.

' Preconditions:
' 1. Open a drawing that contains a flat pattern view of a sheet metal part with
'    one or more forming tool features.
' 2. Modify the x- and y-coordinates in the IModelDocExtension::SelectByID2 methods for the
'    specified VERTEX and FACE.
' 3. Replace install_dir with your SolidWorks installation path.
' Postconditions:
' 1. A punch table is inserted in the drawing.
' 2. Inspect the Immediate window for punch table feature details.
' ---------------------------------------------------------------------------
Imports SolidWorks.Interop.sldworks
Imports SolidWorks.Interop.swconst
Imports System
Imports System.Diagnostics

Partial Class SolidWorksMacro

Dim Part As ModelDoc2
Dim boolstatus As Boolean
    Dim myView As View
Dim myTableAnn As PunchTableAnnotation
Dim MyTable As PunchTable
Dim featRet As Feature
Dim rVar As Object

    Sub main()

        Part = swApp.ActiveDoc
        boolstatus = Part.ActivateView(
"Drawing View1")
        boolstatus = Part.Extension.SelectByID2(
"Drawing View1", "DRAWINGVIEW", 0, 0, 0, False, 0, Nothing, 0)

'Select a vertex in the drawing view to be the origin of all datums in the table
        'All X LOCATION and Y LOCATION table column values will be relative to this datum origin
        boolstatus = Part.Extension.SelectByID2("", "VERTEX", 0.1344949308616, 0.0948467785893, 0, False, 1, Nothing, 0)

'Select a face that contains the punches that will be annotated in the table
        boolstatus = Part.Extension.SelectByID2("", "FACE", 0.1562337360869, 0.1059474450873, 0, True, 2, Nothing, 0)

        myView = Part.SelectionManager.GetSelectedObjectsDrawingView(1)

        myTableAnn = myView.InsertPunchTable(
False, 0.2178779310824, 0.2022819591903, 1, "A", "install_dir\lang\english\punchtable-standard.sldpuntbt")
If myTableAnn Is Nothing Then MsgBox("Failed to insert Punch Table")

        MyTable = myTableAnn.PunchTable
"Default punch table properties:")
"Tag style (swPunchTableTagStyle_e): " & MyTable.TagStyle)
"Starting tag: " & MyTable.StartingValue)
"Merge cells with the punch ID for a given tag? " & MyTable.CombineSameSize)
"Combine rows with the same punch ID? " & MyTable.CombineTags)
"Display dual dimensions? " & MyTable.DualDimensions)
"Display units for dual dimensions? " & MyTable.ShowUnits)
"Punch table annotation count: " & MyTable.GetTableAnnotationCount)

        rVar = MyTable.GetTableAnnotations

        featRet = MyTable.GetFeature
"Feature name: " & featRet.Name)

        boolstatus = Part.ActivateSheet(
End Sub

    Public swApp As SldWorks

End Class



Provide feedback on this topic

SOLIDWORKS welcomes your feedback concerning the presentation, accuracy, and thoroughness of the documentation. Use the form below to send your comments and suggestions about this topic directly to our documentation team. The documentation team cannot answer technical support questions. Click here for information about technical support.

* Required

Subject:   Feedback on Help Topics
Page:   Insert Punch Table Example (VB.NET)
*   I acknowledge I have read and I hereby accept the privacy policy under which my Personal Data will be used by Dassault Systèmes

Print Topic

Select the scope of content to print:


We have detected you are using a browser version older than Internet Explorer 7. For optimized display, we suggest upgrading your browser to Internet Explorer 7 or newer.

 Never show this message again

Web Help Content Version: API Help (English only) 2014 SP05

To disable Web help from within SOLIDWORKS and use local help instead, click Help > Use SOLIDWORKS Web Help.

To report problems encountered with the Web help interface and search, contact your local support representative. To provide feedback on individual help topics, use the “Feedback on this topic” link on the individual topic page.