Skip to content

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

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

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

Download LinceCAD Manual contents