|
|
T:+61 83542400 |
Visit the University web site![]() |
|
AutoLISP - AutoCAD and IntelliCAD's programming language |
|
As an example, it is possible to use lisp to read a line of text in a file describing the x, y and z coordinates of a point in space. Lisp can interpret the information, store the position of the point in space and other commands can then be called to create useful geometry. AutoLISP AutoLISP is Autodesk's implementation of the lisp programming language. The major advantage of using AutoLISP in your AutoCAD or IntelliCAD drawings is that it enables the creation of new commands in AutoCAD.
Other examples We have used AutoLISP to create a new command which, when implemented, reads a huge file which contained the XYZ coordinates of light poles in a local council area. LISP then produced a drawing showing a point at every position and XREFERENCED a cadastral drawing showing the council boundaries. This enabled council to make sure that they were only paying for lighting in their area. Sample AutoLISP programs Many sample AutoLISP programs are available on the Internet. The instructions below provide some guidance on testing them out. Testing an unfamiliar AutoLISP program (simple approach) Copy the AutoLISP file to the directory in which your drawings normally reside. If you have never used the AutoLISP program before, start Windows Notepad and open the LISP file to view it. AutoLISP programs have the .LSP extension. The LISP program may read like 'gobbledgook', but somewhere in it, usually at the beginning, some instruction on how to use the program may be given. Print out the instruction part of the file. The amount of instruction will vary according to the author. Operation Most AutoLISP programs will create a new command when loaded which when executed, will carry out some (new) function. An example is shown below. **(defun c:chgsc () Look at the beginning of the file for a line similar to that marked with the * *. The part that says c:chgsc indicates that the author has decided to create a new command to start the program CHGSC - short for change scale. Syntax Either upper of lower case will work in AutoLISP, it's not case sensitive. Once the LISP file is loaded a new command is created; in this case CHGSC.
Loading the AutoLISP program Any AutoLISP program can be loaded from the command line using the following syntax: (load "filename") The brackets are essential.
(load
"c:/verify/verify.lsp") Once the LISP file has been loaded, you can then type your new command. Loading AutoLISP programs - Method 2: Create a folder for all of your AutoLISP programs so that they are all kept in one place. E.g. create a folder called C:/AutoLISP Load the program with the syntax: (load "C:/AutoLISP/filename.lsp") Loading AutoLISP programs - Method 3 Edit the file ACAD.LSP (or ICAD.LSP) using Windows Notepad and add the "load" command that you have used above into this file. When AutoCAD or IntelliCAD starts, all these LISP files will be loaded, ready to run. An example of part of an ICAD.LSP file is shown below.
(defun S::STARTUP() Error messages It is not uncommon for there to be errors in LISP files, especially those downloaded free of charge from the Internet. Copyright issues If you do use a program created by someone else, keep that person's copyright notice intact in the file and acknowledge their effort.
|