Extended modules > Creo Elements/Direct Sheet Metal > Creo Elements/Direct Sheet Metal customization > Punch
  
Punch
This chapter discusses the following topics:
Parametric Punch Tools
Adding a Parametric Punch Tool of an Existing Type
Parametric Punch Tool Types
Structure of a Parametric Punch Tool Type Definition
Parametric Punch Tool Example
Adding a Parametric Punch Tool Type
Non-Parametric Punch Tool Types
Adding a Non-Parametric Punch Tool and Type Entry
For the punch process, a Creo Elements/Direct Sheet Metal shop definition file contains:
a "Punch Types" table specifying punch tool types (such as "Keyway In").
a set of tool tables. Each of these tables specifies the dimensions and other process parameters of the individual tools of a given punch tool type. For instance, the "Keyway In" table includes a separate row for each keyway in tool. If a given punch tool type is represented by a single punch tool, the associated tool table contains only a single parameter record (a single row of table values).
Creo Elements/Direct Sheet Metal punch tools perform a Creo Elements/Direct Modeling Mill operation on the parts to which they are applied.
Parametric Punch Tools
As of CoCreate Sheet Metal revision 4.5, all punch tool types specified in the sha_demoshop.lsp sample shop definition file are "parametric tools". This means that the user will select the appropriate tool dimension from a selection list at runtime. In the TDB, you (or your TDB administrator) can specify additional tool sizes by adding a row (an additional parameter record) to the associated tool table.
Adding a Parametric Punch Tool of an Existing Type
To add a parametric punch tool of an existing type, you need to add the new punch tool specification (an additional row) to the associated punch tool table. Either use the Technology Database Browser (see Adding a Punch Tool) or edit the underlying TDB table manually.
For example, if you want to add a punch tool of type "rnd", proceed as follows:
1. Open the shop definition file (for instance, your working copy of the sha_demoshop.lsp file).
2. Display the "Round" table in your shop definition file. This table is shown below.
(sha-define-shop-table "rnd"
:TABLE-TITLE "Round"
:COLUMNS
(:DIA :TOOL_ID :DESCR :MIN_THICK :MAX_THICK :PREFERENCE :ADVICE )
:COLUMN-NAMES
( "Dia" "Tool Id" "Descr" "Min Thick" "Max Thick" "Pref" "Advice")
:UNITS
( :mm nil nil :mm :mm nil nil)
:CONTENTS
(
(1.10 "01004" "RW" 0 100 :PREF "-")
(2.00 "01012" "CN" 0 100 :NONPREF "-")
(3.00 "01024" "NE" 0 100 :PREF "-")
(4.00 "01042" "EM" 0 100 :PREF "-")
(8.00 "01116" "TAQ" 0 100 :NONPREF "-")
(10.00 "01136" "TAU" 0 100 :PREF "-")
(12.70 "01158" "TAV" 0 100 :PREF "-")
(20.00 "01190" "TBQ" 0 100 :NONPREF "-")
)
:KEY (:DIA )
:DISPLAY (:DIA :PREFERENCE :ADVICE)
:FLAT-TEXT (:TOOL_ID)
:HELP "sha_rnd"
; unique, not displayable column entries
:PROF_FNC sha-rnd-profile
)
3. Under :CONTENTS, add the line which specifies your additional punch tool. For the "demoshop", each "round" punch tool specification consists of entries for the following columns:
:DIA
The tool diameter.
:TOOL_ID
The tool identification number.
:DESCR
A descriptive tool name.
:MIN_THICK
The minimum material thickness the tool is designed for.
:MAX_THICK
The maximum material thickness the tool is designed for.
:PREFERENCE
Preference status: ":PREF" for preferred tools or ":NONPREF" for non-preferred tools.
:ADVICE
Creo Elements/Direct Sheet Metal fills this column according to checks against :MAX_THICK, and/or :MIN_THICK (if these entries exist).
:FLAT-TEXT
Same as in "The General Structure of Tables".
The following parameter record (tool table row) is an example of an additional round punch tool specification.
(6.00 "01042" "EM" 0 1.5 ":NONPREF" "-")
The hole diameter produced by this new punch tool is 6.00 mm. Its ID number is 01042. Its name is EM. It is a non-preferred tool designed for any thickness of up to 1.5 mm. The "-" entry is the default entry for the :ADVICE column. At runtime, the "-" entry for the :ADVICE column is dynamically replaced by the tool check result when this tool is listed in the tool selection table.
Parametric Punch Tool Types
Each parametric punch tool type is defined through a special C++ or LISP based function. This function defines a sequence of Creo Elements/Direct Modeling 2D commands creating the required punch profile in a special workplane. Adjust points are provided to facilitate the positioning of the punch tool on the workpiece.
For English, the LISP based functions defining these parametric punch tool entities are included in the following file:
$INSTALLDIR/personality/sd_customize/SheetAdvisor/punch_fncs/sha_punch_functions.lsp
For all other languages, the functions are included in the following file:
$INSTALLDIR/personality/<language>/sd_customize/SheetAdvisor/punch_fncs/sha_punch_functions.lsp
If you want to create customized functions for your own parametric punch tools, create a working copy of this file. Use a name such as my_punch_func.lsp for this file.
The appropriate function must be referenced in the :PROF_FNC column of the tool which it defines. Creo Elements/Direct Sheet Metal provides input to this function in the form of all tool table entries for the selected tool type as well as the sheet thickness and the current Creo Elements/Direct Modeling resolution. The function returns output in the form of the resulting profile created in the punch tool workplane.
Creo Elements/Direct Sheet Metal uses this data to build the distance checking zones which are displayed around the punch tool before it is placed on the sheet metal part. Once the user has positioned the tool, Creo Elements/Direct Sheet Metal uses the profile to mill the selected sheet metal part. The milling depth is usually equal to the sheet metal thickness. Creo Elements/Direct Sheet Metal uses the resulting cutout to build the punch feature information.
* 
Please note that the LISP function files are not case-sensitive.
Structure of a Parametric Punch Tool Type Definition
The Creo Elements/Direct Sheet Metal punch tool structure is built upon LISP package definitions and punch tool functions.
LISP Package Definitions
The sample sha_punch_functions.lsp file supplied with Creo Elements/Direct Sheet Metal provides functions for the sheet-advisor package. It uses other functions provided through the open-lisp-interface (oli) package of Creo Elements/Direct Modeling.
(in-package :sheet-advisor)
(use-package :oli)
Functions
The function defined for each punch tool in the sample sha_punch_functions.lsp file must be specified in the :PROF_FNC column of the tool table to which it belongs. By convention, the function name starts with sha- and ends with -profile to identify a function in the Creo Elements/Direct Sheet Metal (sha) package generating the tool profile.
defun sha-<function_name>-profile
The function name declaration is followed by the tool parameters used by this function. The parameter names must match the column names specified in the tool table or the standard parameters :THICKNESS (sheet thickness) and/or :RESOLUTION (current system accuracy). The data for these parameters is taken from the columns of the associated TDB table. For instance, if parameter_1 is defined as slot_length, the applicable dimensions are taken from the slot_length column of the associated tool table. The &allow-other-keys statement deals with any other parameters which are not used by this function.
(
parameter_1
parameter_2
...
parameter_n
thickness
resolution
The next block (starting with let) defines the standard local variables:
result
Used as a return value.
tool-wp
The name of the workplane where the punch profile will be created. The actual name is supplied by the sha-tool-wp function. The tool-wp statement provides the name of the workplane in which the punch tool profile will be positioned.
(let ((result nil)
(tool-wp (sha-tool-wp)
(local-variable1 local-value1)
(... ...)
)
The next block generates the workplane where the punch profile will be created.
(create_workplane :new
:name tool-wp
)
The next block creates the tool profile through regular Creo Elements/Direct Modeling commands. For example:
(POLYGON
(gpnt2d ...)
(gpnt2d ...)
...
(gpnt2d ...))
(ARC :CEN_RAD_ANG
(gpnt2d ...)
radius
angle
)
The next block creates adjust points. The central adjust point must be positioned at the origin (0,0). The other adjust points are positioned around the central adjust point.
(C_POINT
0,0
(gpnt2d x1 y1)
(gpnt2d x2 y2)
(gpnt2d x3 y3)
(gpnt2d .. ..)
(gpnt2d xn yn)
)
The resulting profile is extracted from the workplane through a special Creo Elements/Direct Sheet Metal function.
(setq result (sha-profile-of-wp tool-wp_(PPP
The tool workplane is deleted.
(delete_3d (sha-absolute-name tool-wp))
The result is set to the last LISP value (which serves as the return value).
result
)
)
Parametric Punch Tool Example
The following section is an extract from the sample sha_punch_functions.lsp file supplied with Creo Elements/Direct Sheet Metal. It illustrates the usage of the function syntax discussed in the previous sections. This sample section defines the function for the Connector punch tool.
;=================================================
;
; CONNECTOR
;
;=================================================
(defun sha-con
(
out_length
out_width
in_length
in_width
radius
n_rad
(resolution 0.000001)
)
(let ((result nil)
(tool-wp (sha-tool-wp))
)
(create_workplane :new
:name tool-wp
)
;********* create Profile *******
(POLYGON
(gpnt2d 0 (/ out_width 2))
(gpnt2d (/ in_length 2) (/ out_width 2))
(gpnt2d (/ in_length 2) (/ in_width 2))
(gpnt2d (/ out_length 2) (/ in_width 2))
(gpnt2d (/ out_length 2) 0)
)
(when (> n_rad resolution)
(FILLET :CREATE
:FILLET_RADIUS n_rad
(gpnt2d (/ in_length 2) (/ out_width 2))
)
)
(when (> radius resolution)
(FILLET :CREATE
:FILLET_RADIUS radius
(gpnt2d (/ out_length 2) (/ in_width 2))
)
)
(MIRROR_2D
:SELECT :all_2d
:HORIZONTAL
0,0
)
(MIRROR_2D
:SELECT :all_2d
:VERTICAL
0,0
)
;******** create Adjustpoints ******
(C_POINT
0,0
; (gpnt2d dist 0)
; (gpnt2d (- dist) 0)
; (gpnt2d 0 (* (cos (deg-to-rad 30)) (- dist)))
; (gpnt2d dist (* (cos (deg-to-rad 30)) (- dist)))
; (gpnt2d (- dist) (* (cos (deg-to-rad 30)) (- dist)))
; (gpnt2d 0 (* (cos (deg-to-rad 30)) dist))
; (gpnt2d dist (* (cos (deg-to-rad 30)) dist))
; (gpnt2d (- dist) (* (cos (deg-to-rad 30)) dist))
)
(setq result (sha-profile-of-wp tool-wp))
(delete_3d (sha-absolute-name tool-wp))
result
)
)
Adding a Parametric Punch Tool Type
By using the sample shown in the previous section as a template, you can quickly create your own custom punch tool type. The following guided exercise shows you how to create and implement a triangular punch tool type.
This guided exercise comprises the following stages:
1. Stage 1: Create the Workplane plus Profile plus Adjust Points
2. Stage 2: Declare the New Punch Tool Type in the Punch Types Table
3. Stage 3: Add the Tool Table for the New Punch Tool Type
4. Stage 4: Specify the New Tool Function in the sha_customize File
5. Stage 5: Test the New Punch Tool Type
Stage 1: Create the Workplane plus Profile plus Adjust Points
Proceed as follows:
1. In your working copy of the sha_punch_functions.lsp file (such as my_punch_func.lsp), create a new tool type entry. The following sample generates a workplane plus the profile and the adjust points for a triangular punch tool.
;=====================================================
;
; TRIANGLES
;
;
;=====================================================
(defun sha-tri-profile
(
size
)
(let ((result nil)
(tool-wp (sha-tool-wp))
)
(create_workplane :new
:name tool-wp
)
;********* create Profile *******
(POLYGON
(gpnt2d (- (/ size 2)) (- (/ size 3)))
(gpnt2d (/ size 2) (- (/ size 3)))
(gpnt2d 0 (* (/ size 3) 2))
(gpnt2d (- (/ size 2)) (- (/ size 3)))
)
;********* create Adjustpoints *******
(C_POINT
0,0
(gpnt2d (/ size 2) (* (/ size 3) 2))
(gpnt2d (- (/ size 2)) (* (/ size 3) 2))
(gpnt2d 0 (- (/ size 3)))
)
(setq result (sha-profile-of-wp tool-wp))
(delete_3d (sha-absolute-name tool-wp))
result
)
)
2. Save this file.
* 
Make sure that the cutout definition is compatible with the associated stamp tool.
If you decide to save your new tool definition in a completely separate file, be sure that this file begins with the following package statements:
(in-package :sheet-advisor)
(use-package :oli)
Stage 2: Declare the New Punch Tool Type in the Punch Types Table
Proceed as follows:
1. Open your shop definition file (your working copy of the sha_demoshop.lsp file; for example: my_shop.lsp).
2. Scroll to the "Punch Types" table.
3. Add the name of your new tri punch tool type. The resulting "Punch Types" table is shown below.
:TABLE-TITLE "Punch Types"
:COLUMNS
( :TOOL_TYPE :DESCRIPTION ) ; The :TOOL_TYPE column must exist
:COLUMN-NAMES
("Tool Type" "Description")
:UNITS
( nil nil )
:CONTENTS
(
; v localizable name
("tri" "Triangle")
("rnd" "Round")
("rect_sharp" "Rectangle Sharp")
("rect_rnded" "Rectangle Rounded")
...
Stage 3: Add the Tool Table for the New Punch Tool Type
Proceed as follows:
1. Open the shop definition file (such as my_shop.lsp) to which you want to add the new tool table.
2. Copy an existing tool table or create a new tool table in the shop definition file.
3. In this table, specify the parameter records (dimensions, ID, advice marker etc) for the new tool type.
4. In the :PROF_FNC line, be sure to specify the name of your new punch tool function.
5. Make sure that there is no :PROF_WP statement in your new tool table. :PROF_WP is intended for non-parametric tools.
An example of a tool table for the new tri tool type is provided below.
(sha-define-shop-table "tri"
:TABLE-TITLE "Triangle"
:COLUMNS
(:SIZE :TOOL_ID
:DESCR :MIN_THICK
:MAX_THICK :PREFERENCE :ADVICE
)
:COLUMN-NAMES
( "Size" "Tool Id" "Descr" "Min Thick" "Max Thick" "Pref"
"Advice")
:UNITS
( :mm nil
nil :mm
:mm nil
nil)
:CONTENTS
(
(6.10 "01004"
"TRA" 0
1 :PREF
"-")
(7.00 "01012"
"RVX" 0
1.6 :NONPREF
"-")
(8.00 "01024"
"GL2" 0
2.0 :PREF
"-")
(10.00 "01136"
"OLN" 0
2.0 :PREF
"-")
)
:KEY (:SIZE )
:DISPLAY (:SIZE :PREFERENCE :ADVICE)
:FLAT-TEXT (:TOOL_ID)
; unique, not displayable column entries
:PROF_FNC sha-tri-profile
)
Stage 4: Specify the New Tool Function in the sha_customize File
To ensure that your new tool function is loaded automatically when Creo Elements/Direct Sheet Metal starts, you need to specify the tool function in your sha_customize file.
For instance, if your customized tool function file is named my_punch_func.lsp, you need to append the following line to your sha_customize file:
sha-tdb-load "my_punch_func.lsp"
* 
Make sure that your customized shop file is specified in the sha_customize file. See Implementing Customized TDB Files for details.
Stage 5: Test the New Punch Tool Type
Perform the following steps to test your new punch tool type:
1. Use one of the following methods to load your new punch tool type in Creo Elements/Direct Sheet Metal:
Restart Creo Elements/Direct Sheet Metal
or
If Creo Elements/Direct Sheet Metal is already running, click on the command line at the bottom of the Creo Elements/Direct Sheet Metal window and enter the following command to load the shop definition file:
(sha-tdb-load "my_shop.lsp")
2. In the Punch menu, select Triangle.
3. Click on Tools. The new triangular punch tools are now listed in a separate selection list.
4. Select and apply the triangular punch tool of your choice. The result of this operation should resemble the following example.
Figure 181. Figure 3. Triangular Punch Feature
5. Explore the resulting punch feature.
Non-Parametric Punch Tool Types
In addition to parametric punch tool types, a number of non-parametric punch tool types are provided for use at your discretion. A non-parametric tool is defined by a single parameter record. This implies that such a tool is available in a single size only.
If you want use any of these predefined non-parametric punch tools, declare its tool type in the "Punch Types" table in the shop definition file. Then add the associated tool table to the shop definition file. An illustrated example of the method is provided in Adding a Non-Parametric Punch Tool and Type Entry below.
Alternatively, you can create your own non-parametric punch tools "from scratch". The method is described in the following section.
Adding a Non-Parametric Punch Tool and Type Entry
If you want to add a non-parametric punch tool type to your TDB, complete the following steps:
1. Use Creo Elements/Direct Modeling Create 2D commands or associated macro commands to create the profile of your new punch tool. Add points to this profile for use as adjust points.
2. Save the workplane plus profile in 3D Data format.
3. Add the new punch tool to your shop definition file.
For example, if you want to add a non-parametric punch tool of a new type named "snap-in slot", proceed as follows:
1. Create a tool profile such as the sample shown in the following figure. Make sure that the profile is centered around the origin (0,0) of the workplane.
Figure 182. Figure 4. Sample Profile for a Non-Parametric Punch Tool
2. Add points which can serve as adjust points. Refer to existing punch tools for useful adjust point positions.
3. Save your new tool in the default directory for Creo Elements/Direct Sheet Metal punch tools or in your own punch tool directory. The default directory is:
$INSTALLDIR/personality/SheetAdvisor/punch
* 
Creo Elements/Direct Modeling loads the workplane and part information from the directories that are specified as search directories. To add a directory to the search directories, use the following syntax:
(SEARCH_DIRECTORIES :append "$INSTALLDIR/personality/SheetAdvisor/punch")
Specify a filename by which the tool is easily identified (for example: snap_slot.sdw). If the Top-Level Instance Files button in the File menu is switched off, Creo Elements/Direct Modeling will automatically create the associated .sdwc file along with the .sdw file. If this button is switched on, only a single file (.sdwc) is generated. You can use either method.
Alternatively, specify the full pathname for the file in which you want to save the workplane plus profile of your new punch tool. For example, if your name is Jane and you want to save the new tool file in your Home directory, specify a pathname plus filename such as:
/users/jane/snap_slot.sdw
4. In the "Punch Types" section of your shop definition file, add a definition string such as "Triangle" for the new punch tool type you want to add to your TDB.
5. At the bottom of the "punch tools" section in your shop definition file, add a definition table for your new punch tool. You can either create this table "from scratch" or you can copy and edit an existing punch tool table. A sample table is provided below. This table includes the Home directory path mentioned in the previous step.
(sha-define-shop-table "snap_slot"
:TABLE-TITLE "Snap-in Slot"
:COLUMNS
(:IN_DIA :OUT_DIA :WIDTH :DEPTH :ANGLE :TOOL_ID :DESCR
:MIN_THICK :MAX_THICK :PREFERENCE :ADVICE :PROF_WP)
:COLUMN-NAMES
("Up Rad" "Lo Rad" "Width" "Depth" "Angle" "Tool Id" "Descr"
"Min Thick" "Max Thick" "Pref" "Advice" "Prof WP")
:UNITS
(:mm :mm :mm :deg nil nil nil
:mm :mm nil nil nil)
:CONTENTS (
(10.0 6.0 6.0 10 -12 "SHS7" ""
1 1.7 :PREF "-" "/users/jane/snap_slot.sdw")
)
:KEY (:IN_DIA :OUT_DIA :SLOT_WIDTH :ANGLE :NR_SLOTS)
:DISPLAY (:IN_DIA :OUT_DIA :SLOT_WIDTH :ANGLE :NR_SLOTS :PREFERENCE :ADVICE)
:FLAT-TEXT (:TOOL_ID)
:HELP "/users/name/snap"
)
This table specifies a single value per table column because your (non-parametric) tool is available in a single size only.
* 
Make sure that your customized shop file is specified in the sha_customize file. See Implementing Customized TDB Files for details.
* 
The /users/jane/snap_slot.sdw statement for the Prof WP column is merely an example of a pathname for the file in which you saved your new tool workplane plus profile.
6. Make sure that the directory in which you store your new tool file is specified in your sha_customize file. If you save the new tool in the default punch tool directory, you do not need to specify the full pathname.
7. Optionally, you can test your new non-parametric punch tool. The general procedure is the same as described in Stage 5: Test the New Punch Tool Type.