AutoLISP
LinceCAD has its own AutoLISP interpreter to run routines written for AutoCAD or progeCAD: the same functions, the same data types and the same error messages ("; error: bad argument type…", as in AutoCAD, because many routines compare them in their *error*). Routines ask for points and select objects like any command, with object snaps, rubber band and typed coordinates.
Typing expressions on the command line
When no command is active, anything that starts with ( is evaluated as AutoLISP and the result is written below. If parentheses or quotes are left open, the program shows (_> and waits for more lines.
(setq r (* 2 pi)) 6.28319
Loading .lsp files
- APPLOAD opens the Load Applications (APPLOAD) dialog box: Load a .lsp file… loads a file now; the startup suite is loaded every time the program starts.
- load loads a file from a routine or from the command line:
(load "myroutine"). - When a drawing is opened,
acaddoc.lspandlince.lspare loaded automatically if they are in its folder. At startup, those in the user folder are loaded too. - Security (like SECURELOAD): files in the trusted folders (the user folder, the
lispfolder next to the program and the ones added in APPLOAD) are loaded without asking; files in other folders are confirmed first. APPLOAD can also allow loading from any folder or only from trusted ones. - Files can be in UTF-8 or in Windows-1252, like those of older AutoCAD versions.
New commands with c:
A function whose name starts with c: becomes a command: type its name on the command line like any other.
(defun c:area2 (/ e) (setq e (car (entsel "\nSelect a circle: "))) (princ (strcat "\nArea: " (rtos (* pi (expt (cdr (assoc 40 (entget e))) 2)) 2 2))) (princ))
Data types
32-bit integers (which overflow as in AutoCAD), reals, strings, symbols, lists and dotted pairs, entity names, selection sets, files and functions. Angles are in radians; points are lists of two or three numbers. Comments go from ; to the end of the line or between ;| and |;. Strings accept \n, \t, \", \\ and \e.
Limits
- There are no ActiveX functions (
vla-…,vlax-…), DCL dialog boxes, reactors or separate namespaces per drawing. - entget and entmod work with LINE, CIRCLE, ARC, LWPOLYLINE, TEXT, MTEXT, POINT, INSERT and ATTRIB; entmake creates the same ones except ATTRIB; DIMENSION can be read but not changed; for other entities only the common codes (layer, color…) are read. There is no extended data (XDATA).
- trans converts between the WCS and the UCS; with an entity name or with paper space it returns the point unchanged.
- While a command is active,
(is not evaluated (AutoCAD evaluates it and uses the result as the answer). There is no!variableeither to see the value of a variable: type(princ variable). - Expressions can be nested up to about 8000 levels (recursion included). Esc stops a running routine.
Functions by family
Special forms and control: quote · function · lambda · setq · defun · defun-q · if · cond · while · repeat · foreach · progn · and · or · t · pi · pause · error
Arithmetic: + · - · * · / · 1+ · 1- · abs · fix · float · rem · gcd · min · max · sqrt · expt · exp · log · sin · cos · atan · ~ · logand · logior · lsh
Comparison and predicates: = · /= · < · > · <= · >= · eq · equal · not · null · atom · listp · vl-consp · numberp · zerop · minusp · boundp · type · vl-symbolp
Lists: car · cdr · cadr and the other c…r · cons · list · append · reverse · length · vl-list-length · nth · member · assoc · subst · last · vl-remove · vl-position · vl-sort · vl-remove-if · vl-remove-if-not · vl-some · vl-every · vl-member-if · acad_strlsort · mapcar · apply
Evaluation and symbols: eval · set · read · vl-symbol-name · vl-symbol-value
Strings: strcat · strlen · substr · strcase · itoa · atoi · atof · chr · ascii · wcmatch · vl-string-trim · vl-string-left-trim · vl-string-right-trim · vl-string-search · vl-string-subst · vl-string-translate · vl-string-position · vl-string->list · vl-list->string · vl-string-elt · vl-princ-to-string · vl-prin1-to-string
Units: rtos · distof · angtos · angtof
Geometry: distance · angle · polar · inters · trans
User input: initget · getpoint · getcorner · getdist · getangle · getorient · getreal · getint · getstring · getkword · entsel
Messages: princ · prin1 · print · terpri · prompt · alert · textscr · graphscr
Commands: command · command-s · vl-cmdf
Entities: entlast · entnext · entget · entmod · entmake · entdel · entupd · handent
Selection sets: ssget · ssname · sslength · ssadd · ssdel · ssmemb
Tables, variables and display: tblsearch · tblnext · getvar · setvar · redraw · regen
Files and loading: open · close · read-line · write-line · findfile · getenv · load · vl-filename-base · vl-filename-directory · vl-filename-extension
Errors and system: exit · quit · vl-catch-all-apply · vl-catch-all-error-p · vl-catch-all-error-message · vl-load-com · ver · gc