Programming Overview of LISP (LISt Processing) Language
LISP is an acronym for LISt Processing, a separate programming language that provides hooks into the progeCAD program for customization. LISP is similar to AutoLISP. LISP greatly extends the commands and functionality that are available in progeCAD.
LISP Functions
Each LISP command performs a function. For example, LISP functions can:
- Load other LISP, DCL, or SDS programs and progeCAD files.
- Prompt the user for input or alert the user to a situation.
- Execute standard progeCAD commands.
- Process alphanumeric strings.
- Perform mathematical calculations.
- Store values for later use.
- Read and write files.
- Test for given conditions and respond accordingly.
- Select entities in a drawing.
- Modify entities in a drawing.
- Print information to the screen or to a file.
By writing programs that combine various LISP functions, you can create custom solutions that extend the CAD tools in progeCAD, integrate your drawings with other applications, and automate your work. Using LISP in tandem with progeCAD, you can enhance your CAD workstation by creating high-powered add-on applications for any advanced needs appropriate to your specialty, firm, profession, or industry.
NOTE For more information about compatibility between progeCAD's implementation of LISP and implementations found in other CAD systems, see LISP Compatibility.
LISP Symbols
Integer Numbers
An integer is a number that lacks the decimal point. For example, the numbers 0, 1, -512, and 9597 are all integers. In LISP, the value of an integer ranges from --2,147,483,648 to +2,147,483,647. When a function causes an integer to exceed that range, it is automatically converted to the opposite sign-i.e., -2,147,483,649 becomes 2,147,483,647. Note that you could think of this as wrapping around, so that when you add -1 to -2,147,483,649, you wrap to a +2,147,483,647, as visualized in the following diagram:
Real Numbers
A real number (also known as a "floating point" number) is a number containing the decimal point. Even though LISP displays a real number with six significant numbers (such as 2.00000), real numbers are stored in double-precision floating-point format. This the same as saying there are 14 significant digits of precision-for example, as in 2.0000000000000.
You will see that very large and very small real numbers are expressed in scientific notation, such as 3.44861E-07, which is the same as 0.000000344861. Real numbers in the range between -1 and 1 must contain a leading zero, such as 0.9, 0.0, and -0.1. LISP predefines pi as a real number with the value of 3.14159. LISP provides many functions for working with and converting real numbers.
NOTE A decimal point must be prefixed by a digit. For example, 0.5 is valid but .5 results in an progeCAD error message, "Error: invalid argument list."
Strings
A string is a group of alphanumeric characters surrounded by quotation marks, such as "VPORT" and "Please type your name:". The maximum string progeCAD supports is 132 characters long. A string that consists of "" is called empty.
To use control codes (also known as escape codes), use the backslash ( \ ) character as a prefix. For example, \n is the control code for starting a new line. To show a quotation mark within a string, use \", as in "The screw is 1\" long." LISP provides many functions (all those beginning with str, plus numerous others) for manipulating strings.
Entity Names
An entity name is a unique hexadecimal label given to every entity in the drawing, such as <Entity name: 6abc1236> . In LISP, you never work with the actual entity. Rather, you first find out its entity name; then you work with that entity name. LISP uses the term entity rather than object for historical reasons; however, the two words mean the same thing.
Lists
All of LISP consists of lists. A list is comprised of any numbers or text separated by spaces and surrounded by parentheses, such as (1 2 3), (* pi 2), (cen rad), and ("The answer is: " ANS).
A list of two numbers is commonly used as a 2D x,y-coordinates, such as (1.0 2.0). A list of three numbers is commonly used a 3D x,y,z-coordinates, such as (10.0 11.0 12.0). A special kind of list, called the dotted pair, is used to describe entity data, such as (62 . 1). Dotted pair data is very similar to (though not exactly the same as) DXF codes. For example, (62 . 1) means the entity is colored (group code 62) red, color #1. LISP provides many functions (all those beginning with "ent") for examining entity data.
Selection Sets
A selection set is a grouping of one or more entities. LISP provides many functions (all those beginning with the prefix ss) for creating and working with selection sets.
File Descriptors
A file descriptor is a hexadecimal label assigned to a file when it is opened by LISP, such as <File: #82011>. As with entity data, you never refer directly to the file's name; rather, you work with the file descriptor. LISP can open a file for reading, writing, or appending; it can only work with ASCII files (no binary files) and only provides sequential access (no random access).
Tell me about...
Copying Code Examples from the progeCAD Developer Reference
Programming Overview of SDS (Solutions Development System)