Customizable support files
|
File
|
Description
|
asi.ini
|
Database connectivity link
conversion mapping file.
|
*.dcl
|
AutoCAD Dialog Control Language
(DCL) descriptions of dialog boxes.
|
*.lin
|
AutoCAD linetype definition
files.
|
acad.lin
|
The standard AutoCAD linetype
library file.
|
acadiso.lin
|
The standard AutoCAD ISO
linetype library file.
|
*.lsp
|
AutoLISP program files.
|
|
A user-defined AutoLISP routine
that loads each time you start AutoCAD.
|
|
A user-defined AutoLISP routine
that loads each time you start a drawing.
|
*.mln
|
A multiline library file.
|
|
AutoLISP routines used by
AutoCAD menus. A MNL file must have the same file name as the
MNU file it supports.
|
acad.mnl
|
AutoLISP routines used by the
standard AutoCAD menu.
|
|
AutoCAD generated menu source
files. Contains the command strings and macro syntax that
define AutoCAD menus.
|
acad.mns
|
Source file for the standard
AutoCAD menu.
|
|
AutoCAD menu source files.
Contain the command strings and macro syntax that define
AutoCAD menus.
|
acad.mnu
|
Source file for the standard
AutoCAD menu.
|
*.pat
|
AutoCAD hatch pattern
definition files.
|
acad.pat
|
The standard AutoCAD hatch
pattern library file.
|
acadiso.pat
|
The standard AutoCAD ISO hatch
pattern library file.
|
acad.pgp
|
The AutoCAD program parameters
file. Contains definitions for external commands and command
aliases.
|
acad.psf
|
AutoCAD PostScript Support
file; the master support file for the PSOUT and PSFILL
commands.
|
|
Lists ObjectARX applications
that load when you start AutoCAD.
|
*.scr
|
AutoCAD script files. A script
file contains a set of AutoCAD commands processed as a batch.
|
*.shp
|
AutoCAD shape/font definition
files. Compiled shape/font files have the extension
.shx.
|
acad.unt
|
AutoCAD unit definition file.
Contains data that lets you convert from one set of units to
another.
|
Order
of support file loading when starting AutoCAD
You can
understand the effects that one file may have on another if
you know the order in which files are loaded when you start
the software. For example, you have defined a function in an
AutoLISP routine that is loaded from the acad.lsp file,
but the function does not work when you start AutoCAD. This
occurs because the function has been redefined by the acaddoc.lsp
file, which is loaded after acad.lsp.
Following is
a list of AutoCAD, Express Tools, and user-defined files in
the order they are loaded when you first start the program.
Note: If the user-defined
function S::STARTUP is included in the acad.lsp
or acaddoc.lsp file or a MNL
file, the function is called when you enter a new drawing or
open an existing drawing. Thus, you can include a definition
of S::STARTUP in the LISP startup file to
perform any setup operations. |
Automatically
Load and Execute AutoLISP Routines
As you build
a library of useful AutoLISP routines, you may want to load them each
time you run AutoCAD. You may also want to execute certain commands or
functions at specific times during a drawing session.
AutoCAD
loads the contents of four user-definable files automatically: acad.rx,
acad.lsp, acaddoc.lsp,
and the .mnl file that
accompanies your current menu. By default, the acad.lsp
loads only once, when AutoCAD starts, while acaddoc.lsp
loads with each individual document (or drawing). This
lets you associate the loading of the acad.lsp file with
application startup, and the acaddoc.lsp file with document (or
drawing) startup. The default method for loading these startup files can
be modified by changing the setting of the ACADLSPASDOC
system variable.
If one of
these files defines a function of the special type S::STARTUP,
this routine runs immediately after the drawing is fully initialized.
The S::STARTUP function is
described in S::STARTUP Function—Post-Initialization
Execution. As an alternative, the APPLOAD
command provides a Startup Suite option that loads the specified
applications without the need to edit any files.
The acad.lsp
and acaddoc.lsp startup files are not provided
with AutoCAD. It is up to the user to create and maintain these files.
Automatically
Load ObjectARX Applications
The acad.rx
file contains a list of the ObjectARX program files that are loaded
automatically when you start AutoCAD. You can edit this file with a text
editor or word processor that produces files in ASCII text format. You
can customize this file as you want, adding to or deleting from its
contents and making the appropriate ObjectARX programs available for
use. As an alternative, the APPLOAD command
provides a Startup Suite option that loads the specified applications
without the need to edit any files.
Because
AutoCAD searches for the acad.rx file in the
order specified by the library path, you can have a different acad.rx
file in each drawing directory. This makes specific ObjectARX programs
available for certain types of drawings. For example, you might keep 3D
drawings in a directory called AcadJobs/3d_dwgs.
If that directory is set up as the current directory, you could copy the
acad.rx file into that directory and modify it
in the following manner:
If you place
this new acad.rx file in the AcadJobs/3d_dwgs
directory and you start AutoCAD with that as the current directory,
these new ObjectARX programs are then loaded and are available from the
AutoCAD prompt line. Because the original acad.rx
file is still in the directory with the AutoCAD program files, the
default acad.rx file will be loaded if you
start AutoCAD from another directory that does not contain an acad.rx
file.
You can load
ObjectARX programs from an .mnl file using the
arxload function. This ensures that an
ObjectARX program, required for proper operation of a menu, will be
loaded when the menu file is loaded.
You can also
autoload many ObjectARX-defined AutoCAD commands (see Command
Autoloader and "autoarxload"
in the AutoLISP Reference).
acad.lsp—Automatically
Load AutoLISP
The acad.lsp
file is useful if you want to load specific AutoLISP routines every time
you start AutoCAD. When you start AutoCAD, the program searches the
library path for an acad.lsp file. If it finds
one, it loads the file into memory.
The acad.lsp
file is loaded at each drawing session startup when AutoCAD is launched
from the Windows desktop. Because the acad.lsp
file is intended to be used for application-specific startup routines,
all functions and variables defined in an acad.lsp
file are only available in the first drawing. You will probably want to
move routines that should be available in all documents from your acad.lsp
file into the new acaddoc.lsp file.
The
recommended functionality of acad.lsp and acaddoc.lsp
can be overridden with the ACADLSPASDOC
system variable. If the ACADLSPASDOC system
variable is set to 0 (the default setting), the acad.lsp
file is loaded just once; upon application startup. if ACADLSPASDOC
is set to 1, the acad.lsp file is reloaded
with each new drawing.
The ACADLSPASDOC
system variable is ignored in SDI (single document interface)
mode. When the SDI system variable
is set to 1, the LISPINIT system
variable controls reinitialization of AutoLISP between drawings. When LISPINIT
is set to 1, AutoLISP functions and variables are valid in the current
drawing only; each time you start a new drawing or open an existing one,
all functions and variables are cleared from memory and the acad.lsp
file is reloaded. Changing the value of LISPINIT
when the SDI system variable is set to 0
has no effect.
The acad.lsp
file can contain AutoLISP code for one or more routines, or just a
series of load
function calls. The latter method is preferable, because modification is
easier. If you save the following code as an acad.lsp
file, the files mysessionapp1.lsp, databasesynch.lsp,
and drawingmanager.lsp are loaded every time
you start AutoCAD.
Note:
Do not modify the reserved acad2000.lsp
file. Autodesk provides the acad2000.lsp file,
which contains AutoLISP defined functions that are required by AutoCAD.
This file is loaded into memory immediately before the acad.lsp
file is loaded.
acaddoc.lsp—Automatically
Load AutoLISP
The acaddoc.lsp
file is intended to be associated with each document (or drawing)
initialization. This file is useful if you want to load a library of
AutoLISP routines to be available every time you start a new drawing (or
open an existing drawing). Each time a drawing opens, AutoCAD searches
the library path for an acaddoc.lsp file. If
it finds one, it loads the file into memory. The acaddoc.lsp
file is always loaded with each drawing regardless of the settings of ACADLSPASDOC
and LISPINIT.
Most users
will have a single acaddoc.lsp file for all
document-based AutoLISP routines. AutoCAD searches for an acaddoc.lsp
file in the order defined by the library path; therefore, with this
feature, you can have a different acaddoc.lsp
file in each drawing directory, which would load specific AutoLISP
routines for certain types of drawings or jobs.
The acaddoc.lsp
file can contain AutoLISP code for one or more routines, or just a
series of load
function calls. The latter method is preferable, because modification is
easier. If you save the following code as an acaddoc.lsp
file, the files mydocumentapp1.lsp, build.lsp,
and counter.lsp are loaded every time a new
document is opened.
AutoCAD
searches for an acaddoc.lsp file in the order
defined by the library path; therefore, you can have a different acaddoc.lsp
file in each drawing directory. You can then load specific AutoLISP
routines for certain types of drawings or jobs.
Note:
Do not modify the reserved acad2000doc.lsp
file. Autodesk provides the acad2000doc.lsp
file, which contains AutoLISP-defined functions that are required by
AutoCAD. This file is loaded into memory immediately before the acaddoc.lsp
file is loaded.
The term menu
file actually refers to the group of files that work together to
define and control the appearance and functionality of the menu areas.
The following table describes the AutoCAD menu file types.
AutoCAD menu files
|
File type
|
Description
|
MNU
|
Template menu file.
|
MNC
|
Compiled menu file. This binary
file contains the command strings and menu syntax that defines
the functionality and appearance of the menu.
|
MNR
|
Menu resource file. This binary
file contains the bitmaps used by the menu.
|
MNS
|
Source menu file (generated by
AutoCAD).
|
MNT
|
Menu resource file. This file
is generated when the MNR file is unavailable, for example,
read-only.
|
MNL
|
Menu LISP file. This file
contains AutoLISP expressions that are used by the menu file
and are loaded into memory when a menu file with the same file
name is loaded.
|
Use the MENU
command to load a new menu. Use the MENULOAD
and MENUUNLOAD
commands to load and unload additional menus (called partial menus) and
to add or remove individual menus from the menu bar.
AutoCAD
stores the name of the last loaded menu in the system registry.
This name is also saved with the drawing, but it is used only for
backward compatibility. When you start AutoCAD, the last menu used is
loaded. As of Release 14, AutoCAD no longer reloads the menu between
drawings.
AutoCAD
finds and loads the specified file according to the following sequence.
(This sequence is also used when AutoCAD loads a new menu with the MENU
command.)
-
AutoCAD looks for a
menu source file (MNS) of the given name, following the library
search procedure.
-
If an MNS file is
found, AutoCAD looks for a compiled menu file (.mnc) of the same
name in the same directory. If AutoCAD finds a matching MNC file
with the same or later date and time as the MNS file, it loads the
MNC file. Otherwise, AutoCAD compiles the MNS file, generating a new
MNC file in the same directory, and loads that file.
-
If an MNS file is not
found, AutoCAD looks for a compiled menu file (.mnc) of the given
name, following the library search procedure. If AutoCAD finds the
MNC file, it loads that file.
-
If AutoCAD doesn't
find either a MNS or a MNC file, it searches the library path for a
menu template file (.mnc) of the given name. If this file is found,
it compiles an MNC and MNS file, then loads the MNC file.
-
If AutoCAD doesn't
find any menu files of the given names, an error message is
displayed and you are prompted for another menu file name.
-
After finding,
compiling, and loading the MNC file, AutoCAD looks for a menu LISP
file (.mnl), using the library search procedure. If AutoCAD finds
this file, it evaluates the AutoLISP expressions within that file.
The acad.mnl
file contains AutoLISP code used by the standard menu file, acad.mnu.
The acad.mnl file is loaded each time the acad.mnu file is loaded.
Each time
AutoCAD compiles an MNC file it generates a menu resource file (MNR)
which contains the bitmaps used by the menu. The MNS file is an ASCII
file that is initially the same as the MNU file (without comments or
special formatting). The MNS file is modified by AutoCAD each time you
make changes to the contents of the menu file through the interface
(such as modifying the contents of a toolbar).
Although the
initial positioning of the toolbars is defined in the MNU or MNS file,
changes to the show/hide and docked/floating status or changes to the
toolbar positions are recorded in the system registry. After an MNS file
has been created, it is used as the source for generating future MNC,
and MNR files. If you modify the MNU file after an MNS file has been
generated, you must use the MENU command
to explicitly load the MNU file so that AutoCAD will generate new MNS
and MNC files and your changes will be recognized.
Note:
If you use the interface to modify the toolbars, you should cut
and paste the modified portions of the MNS file to the MNU file before
deleting the MNS file.
The MENU
command initially requests the MNS or MNC file. To reload a modified MNU
file, choose the Menu Template item from the file type list, and then
choose the MNU file from the list of files. Doing so protects the MNS
file from accidentally being rebuilt, thus losing any toolbar or partial
menu modifications done through the interface. While building and
testing a menu file, you may find this procedure awkward. The following
AutoLISP routine defines a new command, MNU,
which reloads the current MNU file without going through all the
prompts.
(command "_menu" (strcat (getvar "menuname") ".mnu"))
If you add
this code to your acad.lsp file, the MNU command is automatically
defined when you restart AutoCAD.
acad.mnl—Automatically
Load AutoLISP Menu Functions
The other
type of file that AutoCAD loads automatically accompanies your current
menu file and has the extension .mnl. When
AutoCAD loads a menu file, it searches for an MNL file with a matching
file name. If it finds the file, it loads the file into memory.
This
function ensures that AutoCAD loads the AutoLISP functions that are
needed for proper operation of a menu. As an example, the standard
AutoCAD menu, acad.mnu, relies on the file acad.mnl
being loaded properly. This file defines numerous AutoLISP functions
used by the menu. The MNL file is loaded after the acaddoc.lsp
file.
Note:
If a menu file is loaded with the AutoLISP command
function (with syntax similar to (command "menu"
"newmenu") ), the associated MNL
file is not loaded until the entire AutoLISP routine has run.
For example,
if you create a custom menu called newmenu.mnu
and you need to load three AutoLISP files (new1.lsp,
new2.lsp, and new3.lsp)
for the menu to work properly, you should create an ASCII text file
named newmenu.mnl as follows:
(princ "\nNewmenu utilities... Loaded.")
In this
example, calls to the princ
function can be used to display status messages. The first use of princ
displays the following on the command line:
Newmenu
utilities... Loaded.
The second
call to princ exits the AutoLISP
function. Without this second call to princ,
the message would be displayed twice. As mentioned previously, you can
include the onfailure argument with
calls to the load
function as an extra precaution.
S::STARTUP
Function—Post-Initialization Execution
The startup
LISP files (acad.lsp, acaddoc.lsp,
and .mnl) all load into memory before the
drawing is completely initialized. Typically, this does not pose a
problem, unless you want to use the command
function, which is not guaranteed to work until after a drawing is
initialized.
If the
user-defined function S::STARTUP
is included in an acad.lsp, acaddoc.lsp
or a .mnl file, it is called when you enter a
new drawing or open an existing drawing. Thus, you can include a
definition of S::STARTUP in the
LISP startup file to perform any setup operations.
For example,
if you want to override the standard HATCH
command by adding a message and then switching to the BHATCH
command, use an acaddoc.lsp file that contains
the following:
(alert "Using the BHATCH command!")
(princ "\nEnter OLDHATCH to get to real HATCH command.\n")
(command "undefine" "hatch")
(princ "\nRedefined HATCH to BHATCH!\n")
Before the
drawing is initialized, new definitions for HATCH
and OLDHATCH are defined with the defun
function. After the drawing is initialized, the S::STARTUP
function is called and the standard definition of HATCH
is undefined.
Note:
To be appended, the S::STARTUP
function must have been defined with the defun-q
function rather than defun.
Because an S::STARTUP
function can be defined in many places (an acad.lsp,
acaddoc.lsp, .mnl
file, or any other AutoLISP file loaded from any of these), it's
possible to overwrite a previously defined S::STARTUP
function. The following example shows one method of ensuring that your
start-up function works with other functions.
... your start-up function ...
(setq S::STARTUP (append S::STARTUP MYSTARTUP))
The previous
code appends your start-up function to that of an existing S::STARTUP
function, and then redefines the S::STARTUP
function to include your start-up code. This works properly regardless
of the prior existence of an S::STARTUP
function.
Tips
for Coding AutoLISP Startup Files
If an
AutoLISP error occurs while you are loading a startup file, the
remainder of the file is ignored and is not loaded. Files specified in a
startup file that do not exist or that are not in the AutoCAD library
path generally cause errors. Therefore, you may want to use the onfailure
argument with the load function. The
following example uses the onfailure
argument:
(princ (load "mydocapp1" "\nMYDOCAPP1.LSP file not loaded."))
(princ (load "build" "\nBUILD.LSP file not loaded."))
(princ (load "counter" "\nCOUNTER.LSP file not loaded."))
If a call to
the load function is successful, it
returns the value of the last expression in the file (usually the name
of the last defined function or a message regarding the use of the
function). If the call fails, it returns the value of the onfailure
argument. In the preceding example, the value returned by the load
function is passed to the princ
function, causing that value to be displayed on the command line. For
example, if an error occurs while AutoCAD loads the mydocapp1.lsp
file, the princ function displays the
following message and AutoCAD continues to load the two remaining files:
MYDOCAPP1.LSP
file not loaded.
If you use
the command
function in an acad.lsp, acaddoc.lsp
or MNL file, it should be called only from within a defun
statement. Use the S::STARTUP function
to define commands that need to be issued immediately when you begin a
drawing session. The S::STARTUP
function is described in S::STARTUP Function—Post-Initialization
Execution.
When you
automatically load a command using the load
or command functions, the command's
definition takes up memory whether or not you actually use the command.
The AutoLISP autoload function makes a
command available without loading the entire routine into memory. Adding
the following code to your acaddoc.lsp file
automatically loads the commands CMD1, CMD2,
and CMD3 from the cmds.lsp
file and the NEWCMD command from the newcmd.lsp
file.
(autoload "CMDS" '("CMD1" "CMD2" "CMD3"))
(autoload "NEWCMD" '("NEWCMD"))
The first
time you enter an automatically loaded command at the Command prompt,
AutoLISP loads the entire command definition from the associated file.
AutoLISP also provides the autoarxload
function for ObjectARX applications. See "autoload"
and "autoarxload"
in the AutoLISP Reference.
acadvba.arx—Automatically
Load VBA
You cannot
load VBA until an AutoCAD VBA command is issued. If you want to load VBA
automatically every time you start AutoCAD include the following line in
the acad.rx file:
You can
automatically run a macro in the acad.dvb file
by naming the macro AcadStartup. Any macro in your acad.dvb
file called AcadStartup automatically executes when VBA loads.
acad.dvb—Automatically
Load a VBA Project
The acad.dvb
file is useful if you want to load a specific VBA project that contains
macros you want each time you start AutoCAD. Each time you start a new
AutoCAD drawing session, AutoCAD searches for the acad.dvb
file and loads it.
If you want
a macro in your acad.dvb file to run each time
you start a new drawing or open an existing one, add the following code
to your acaddoc.lsp file:
(command "_-vbarun" "updatetitleblock")
Automatically
Loading a VBA Project
There are
two different ways to load a VBA project automatically:
When VBA is loaded it
will look in the AutoCAD directory for a project named acad.dvb.
This file will automatically load as the default project
Any project other than
the default, acad.dvb, can be used by
explicitly loading that project at startup using the VBALOAD
command. The following code sample uses the AutoLISP startup file to
load VBA and a VBA project named myproj.dvb when
AutoCAD is started. Start notepad.exe and
create (or append to) acad.lsp the following
lines:
(defun
S::STARTUP()
(command "_VBALOAD" "myproj.dvb")
)
Automatically
Running a VBA Macro
You can
automatically run any macro in the acad.dvb
file by calling it with the command line version of VBARUN
from an AutoCAD startup facility like acad.lsp.
For example, to automatically run the macro named drawline,
first save the drawline macro in the acad.dvb
file. Next, invoke notepad.exe and create (or
append to) acad.lsp the following lines:
(command "_-vbarun" "drawline")
You can
cause a macro to run automatically when VBA loads by naming the macro AcadStartup.
Any macro in your acad.dvb file called AcadStartup
will automatically get executed when VBA loads.