BabaCAD LISP Syntax and function/command list



;; Defines a function

defun

(defun myfun (a1 a2 / b1 b2)
 (setq b1 (* a1 a2))
 (setq b2 (/ a1 a2))
 (+ b1 b2)
)

;;Execute the function:
> (myfun 6 3) ; Returns 20

a1,a2,... -> input (or global vars) arguments
b1,b2,... -> local (function scope) variables







;; Defines a new BabaCAD command

defun c:cmdname

(defun c:test (/ b1 b2)
 (setq b1 (* 64 8.3))
 (setq b2 (/ b1 3))
 (+ b1 b2)
)

;;Execute the command in the command window:
> test ; Returns 708.27

must have no input arguments
b1,b2,... -> local (function scope) variables







;; arithmetic functions and operators (+,-,*,/,<,<=,>,=,/=)

arithmetics

(+ 2 3)

; Returns 5

arg1,arg2,... -> multiple input arguments
output -> number (if input args are numbers) or T/nil (if comparison operators applied)




;; executes BabaCAD command

command

(command "line" "20,20" "35,30" "")

; Returns nil

arg1 -> BabaCAD command name
arg2,arg3,arg4,.... -> command parameter list





Later to be described:

(Definitions can be also found on net [search for LISP+function_name])

- quote
- not
- or
- and
- if
- while
- repeat
- eq (is expr equal)
- equal (is equal)
- length (list or string length)
- nullp (is list empty?)
- listp (is cell's type a list)
- setq (set variable)
- car (first element of the list)
- cdr (all except the first element of a list)
- cadr (equiv to (car (cdr)))
- append (append an element to the end of a list)
- cons (constructs list or cons)
- list
- assoc
- subst
- nth
- redraw
- getpoint
- getstring
- getreal
- getint
- getdist
- getvar
- setvar
- princ
- prin1
- print
- prompt
- entsel
- entnext
- entlast
- entget
- entmod
- ssadd
- ssget
- ssname
- ssdel
- sslength
- sin
- cos
- atan
- sqrt
- polar
- strcat
- substr
- strlen
- strcase
- vl-remove
- polar
- angle
- distance
- inters
- bc-refresh
- bc-wait
- bc-entext
- pi










Legal Stuff
Trademarks: BabaCAD is a trademark of Mirza Coralic. DXF is a trademark of AutoDesk. Other product names mentioned here are trademarks of their respective owners