A generic method for automatic shape recognition on two-dimensional contours, particularly used for recognizing punch shapes for progressive dies, is presented in this article. In this work, shapes of two-dimensional contours are defined by shape templates using a sequence of symbols, lists, and numbers, and their definitions are stored in a specially designed database for the minimum number of shape definitions to be retrieved during shape recognition for optimal computational efficiency. When a contour is input from a computer-aided design system for shape recognition, the computer-aided design data are translated into shape components and input to the shape recognition device. Upon successful recognition of a shape, the shape code will be composed and its dimensional values will be extracted. Standard or special punch purchase code may be created automatically through this method.