CADDIT CAD CAM CNC Software - download AutoCAD compatible design software progeCAD Alibre T-FLEX and more
CADDIT Website Knowledge Base Search:

progeCAD Help

Welcome to progeCAD
Working with progeCAD
Command Reference
CAD System Variables
Programming progeCAD
Full Index (caution - 400kb)

Further Links:

Download progeCAD
Register progeCAD


T-FLEX PLM tutorial (PDF)
progeCAD IntelliCAD and AutoCAD training 
CATIA 2D 3D design tutorial
Alibre CAD/CAM basic tutorial


Educational CAD Software Solutions
Python scripting for DOS and Windows
Other free software downloads
CADDIT CAD CAM Forum Australia

(defun [c:] name ([arg1 arg2 ...] / [local-var1 local-var2 ...]) expression)

Create a LISP function.

When you write a LISP file, the file itself is not actually the function. Rather, one LISP file contains one or more functions (or programs) that are all available when the file is loaded with the load function.

The name of a function must be defined in the first statement using the defun function. This function is the first actual command within the program. It begins with an open parenthesis, which closes at the end of the program.

The defun function is followed by the name of your function or program. Once a name is selected, you have a few choices:

  • First, you can do nothing by adding ( ). This indicates that any variables used in the program are global, meaning they don't lose their value once the program ends. For example, the variable A defined as 12 would be 12 for any other program in the LISP file as well:
  • (defun newfunc ( )



  • Another option is to make all variables local to the program. For instance, if you defined N to equal 15, it would be 15 only for this particular program while it is running. To show that the variable is local, precede it with a forward slash (/) after the name of the program:
  • (defun newfunc ( / N)



  • Sometimes you may want to pass an argument to the program. This means that the variable will be assigned a value from outside of the currently running program. Place these variables before the slash:
  • (defun newfunc (A / N)



Once your function is defined with all its variables, you can choose to use the C: option. Prefixing the C: to the function name enables the command name to be entered without parenthesis at the command prompt of progeCAD. This makes it look like any other progeCAD command such as Line, Arc, and Circle.

(defun C:newfunc ( A / N)



NOTE The C: has nothing to do with your computer's C: drive. In LISP, it is short for "command" and tells progeCAD to treat the LISP function like an progeCAD command.

Following the lists of variables, the expression that will make up the body of the program must be entered before the closing parenthesis.


Code Results:
(defun newfunc ( ) . . .) May use global variables.
(defun newfunc (var1 var2). . . ) Newfunc receives two outside values.
(defun newfunc (/ var1 var2). . .) Newfunc has two local variables.


(atoms-family format [symbol1 symbol2 ...])

(command cmd [arguments] ...)

(menucmd string)

LISP Compatibility

Programming Overview of LISP (LISt Processing) Language

CADDIT® is a registered trademark in Australia. All Rights Reserved. Comments concerning the content of this site should be addressed to our webmaster. progeCAD is a trademark of ProgeCAD srl. Autodesk® and AutoCAD® are both registered trademarks or trademarks of a third party, and used only for comparison purposes. All other trademarks, trade names or company names referenced herein are used for identification only and are the property of their respective owners. Legal and Terms of Use. Google. Find us on Google+.