You are on page 1of 3

Home

Contact
Site Map

Custom Search Search

AutoLISP
Beginners' Tutorials
Intermediate Tutorials
Advanced Tutorials
Application Tutorials
Tips'n'Tricks
Visual LISP
Beginners' Tutorials
Intermediate Tutorials
DCL
Beginners' Tutorials
Intermediate Tutorials
VBA
VBA Tutorials
VBA Applications
Tips'nTricks
AutoCAD
Customization Tutorials
Tips'n'Tricks
Reference
AutoLISP Functions
Visual LISP Sample Files
DXF Group Codes
The AutoCAD APIs
DCL Tile Attributes
AutoLISP DCL Functions
System Variables
AutoCAD Object Model
Sin and Cos Functions
VLAX Enumeration
Download
Forum

Loading AutoLISP Files


by Kenny Ramage

Note: One of the most important things to remember about loading AutoLisp Routines is to ensure that your Lisp files and
any support files (i.e DCL Files; DAT Files; etc) are in your AutoCad search path. (I dedicate a directory to all my Lisp files
and relevant support files.

There are numerous ways of loading AutoLisp Files :

Command Line Loading


The simplest is from the AutoCad command line.
The syntax for loading AutoLisp files is :
(load "filename")

The.lsp extension is not required.

Menu Loading
The following code samples are one way of loading AutoLisp files from a menu.

Pull Down Menu's :


***POP12
T_Steel [Steel Menu]
T_Beams [Drawing Setup]^C^C^P+
(cond ((null C:DDSTEEL) (prompt "Please Wait...")(load "DDSTEEL")))
DDSTEEL

Toolbars :
***TOOLBARS
**STEEL
TB_DDSTEEL [_Button("Steel", "STEEL.bmp",
"STEEL32.bmp")]^C^C^P+
(cond ((null C:ddsteel) (prompt "Please Wait...")(load "ddsteel"))) ddsteel

This method of loading Lisp files first checks to see if the routine is already loaded. If it is, it runs the routine. If it is not, it
first loads the routine, then runs it. Clever Hey?

Acad.Lsp File
The Acad.Lsp file is a useful way of loading a library of AutoLisp routines.
Each time you start a drawing AutoCad searches the library path for an Acad.Lsp file. If it finds one, it loads the file into
memory.

You could use the normal load function (load "filename") in your Acad.Lsp file but if an error occurs whilst attempting to
load one of your routines, the remainder of the file is ignored and is not loaded.
Therefore, you must use the on failure argument with the load function :

(load "Lispfile1" "\nLispfile1 not loaded")


(load "Lispfile2" "\nLispfile2 not loaded")
(load "Lispfile3" "\nLispfile3 not loaded")

The .MNL File


The other type of file that AutoCad loads automatically is the .MNL file.

If you have a partial menu file it can also have it's own .MNL file. Just remember that the .MNL file must have exactly the
same name as your partial menu file. (except for the .MNL extension, of course.)

You can load Lisp files from this file using the load function exactly the same as you did in the Acad.Lsp file.

Command Autoloader
When you automatically load a command from your Acad.Lsp file (or a .MNL file) the commands definition consumes your
systems resources whether you actually use the command or not. The Autoload function makes a command available
without loading the entire routine into memory.

(Autoload "Utils" '("Utils1" Utils2" "Utils3"))


(Autoload "DDSteel" '("DDSteel"))

This would automatically load the commands Utils1, Utils2 and Utils3 from the Utils.Lsp file and DDSteel from the
DDSteel.Lsp file.

S::Startup Function
If the user defined function S::Startup is included in the Acad.lsp or a .MNL file, it is called when you enter a new drawing
or open an existing drawing.

For example, say that you wanted to override the standard AutoCad LINE and COPY commands with versions of your own,
your Acad.Lsp file would something like this :

(defun C:LINE ()
.....Your Definition.....
)
(defun C:COPY ()
.....Your Definition.....
)
(defun S::Startup ()
(command "Undefine" "LINE")
(command "Undefine" "COPY")
)

Before the drawing is initialised, new definitions for LINE and COPY are defined. After the drawing is initialised, the
S::Startup function is called and the standard definitions of LINE and COPY are undefined.
AutoLISP
AutoLISP Beginners' Tutorials
AutoLISP Intermediate Tutorials
AutoLISP Advanced Tutorials
AutoLISP Application Tutorials
AutoLISP Tips'n'Tricks

AfraLISP Archive
‘Hey, what's happened to AfraLISP?’ If you've visited our site before, you'll notice some big changes. We're currently
revamping the entire site to bring you updated tutorials and a better user experience. However, if there's something you can't
find, the AfraLISP Archive contains a full copy of the original site as originally created by Kenny Ramage.

AutoLISP Learning Resources


Lee Mac - AutoLISP Tutorials and Programmes
Draftsperson.net - AutoLISP Tutorials
Jeffery P Sanders - AutoLISP Tutorials
Ron Leigh - AutoLISP Tutorials
Pixel Graphics Inc. - AutoLISP Tutorials
A'CAD Solutions - AutoLISP Tutorial
CAD Digest - AutoLISP Tutorials

Online Books
The ABC's of AutoLISP
The Visual LISP Developer's Bible

AutoLISP Forums
CADTutor
Autodesk Discussion Groups
Autodesk User Group International (AUGI)
The Swamp

122 Tutorials and reference documents published at AfraLISP so far.

Terabyte HDMI to VGA Converter...


Hdmi male to vga female adaptor please use good quality vga (male) to
₹ 274
vga (male)...
Amazon.in
API Example 3D Drawing Convert DAT

Back to top
Home
Cared for by David Watson © 2018

You might also like