A. Basic LISP functions:
1. Defun :
(defun symbol arguments term1 …)
(defun MYFUNC (a b c)
Ex. (myfunc 1 2 3)
In Defun function:
- To set all variables to global use () after function name
- To set variables to local write variable names as (/ a pt1) after function name
- To use function name as command line write c:functionname ()
This sets the value of a symbol to an expression and returns that value.
(setq symbol1 value1 [symbol2 value2] … )
Ex. (setq x 0)
If you want to set variable to nil then use this
(setq val nil)
3. getpoint : (check User Input functions )
(getpoint [point] [prompt])
Select any point in GA.
Ex.2 (getpoint “Select point”)
Select point» (select any point in ga and it will return Point x and y values.)
4. Princ : (check Display Controls )
This function Prints the Specified expression & returns expression in Command Window.
(princ [expression [file_descriptor]])
DraftSight Function Syntax.
- (Func String [number])
- String is called Required argument
- number is called Optional argument.
You can use DraftSight commands in LISP as below.
B. Data Types:
Are numbers ranging between -32768 and +32767
Includes numbers with decimal points such as 2.5
3. Strings: (See Strings functions )
Strings are text
4. Lists: (See List Handling and Manipulation)
List contains more than one element
Ex. ( 55 66 10)
A single element as 1 or A
Data is stored in these variables. It is collection of letters or numbers
Ex. (setq a 10)
Where ‘a’ is variable and 10 is value assigned to variable ‘a’
How to know data type ?
Function : Type
Type function name will show data type of variable next to it for ex.
: (type “0”)
: (type 2)
: (type 2.5)
If you type text without quotation then it will return as nil/
Next 5. If Repeat While foreach