LISP is a full-featured, interpretive programming language (full name List Processor, which is list processing language), It is a sort of independent programming language embedded for ZWCAD customization. LISP greatly extends most of the available commands and functions of ZWCAD. LISP is similar to AutoLISP so that you can use the majority of applications written with AutoLISP in ZWCAD.
A LISP command stands for a function. Lisp function can perform the following actions :
Load other LISP, DCL, SDS application or ZWCAD files
Prompt user to do relevant operations in the certain situation.
Execute standard command in ZWCAD
Handle character string with arbitrary length
Do mathematic calculation
Store variable value used lately
Test and respond to the given condition.
Select entity in drawing session.
Modify the selected entity in drawing session.
Export relevant information into screen or a file.
You can produce customize resolution with application comprised of compound variant LISP functions. You can automate your job by extending CAD tools in ZWCAD or apply other applications into ZWCAD. LISP can be used to produce any application you need in the special industries to intensify the CAD platform.
Application of LISP expressions
LISP has its particular functions and syntax. LISP codes are capable of tested directly without preparing extra procedure. Two syntaxes are provided in LISP, the first one putting the operator in front of the operating number, in which operators can be taken as functions with specific features, the operating number is process by functions. Each statement is separated by a blank.
The second syntax divides the statement into two items within each bracket: function name as the first item and the parameters or variables of the function is second item.
Create a LISP program
Steps to write application using LISP:
Open a text edited window such as NOTEBOOK.
Write code in the text edited window.
Saves the new code file with the desired path and file name from File-Save As menu option, extension name as 1st.
Verify the code input.
The following properties are contained in LISP functions:
The codes are displayed in indent mode as other program languages do, but take no effects on performing programs.
Newline is used to facilitate understanding and reading, and place multi-row codes in one line, which does not effect performing the program.
All LISP statements are contained in the brackets which always appear in pairs.
If multiple brackets pairs are contained in a statement, execute from the interior bracket.
Text in codes appears behind the semicolon is a kind of annotation. Any text with semicolon in front will be ignored by programs.
All LISP functions return value to the other function that invoke them. By default, the value is calculated by the last expression. Generally the function princ without character string parameter follows the function that its name precede with a prefix "c:". This function is aimed at exiting program without returning any value.
Load and Run LISP Program
LISP program is available only after loading, while how to apply a LISP program relies on the program itself, if functions are created in programs, it can be performed just like executing commands in ZWCAD. Most of the LISP functions are provided with prompts instructing how to use them. You can load LISP program to ZWCAD before executing this program as performing APPLOAD command. In addition to input from command line, ZWCAD provides another direct way of performing commands: customize menu which is used for running LISP program. No more descriptions for the specific procedures here.
Sample of LISP program
The following LISP program explains how to create a green TEST layer, and draw a closed polyline on that layer.
(defun C:testlisp (/)
(setvar "cmdecho" 0)
(command "-layer" "t" "test" "m" "test" "c" "green" "test" "l" "continuous"
"test" "lw" "0.5" "test" "")
(command "pline" "-2,-3,0" "6, 4, 0" "1, -10, 0" "-11, -9, 0" "-12, -1, 0" "-6, 2, 0" "-1, 7, 0" "c")
(command "zoom" "e" "")
(setvar "cmdecho" 1)
User can reference "LISP document" from Developer's help, to view LISP functions as well as relative tutorials that ZWCAD supports(it's recommended to reference specific instructions from "Help"-"Developer's help").