Written by Eric Gates.
Using acad.lsp and acaddoc.lsp to set application variables, and drawing variables
A good place to start with AutoCAD customization is with the basic use of Lisp. Which means first knowing how acad.lsp and acaddoc.lsp work, and where these files should be located.
When AutoCAD starts, it searches the support file search path for an acad.lsp file.
If the file is found it reads the contents and loads it in memory. By default the acad.lsp file is only read once at the application start-up.
The ACADLSPASDOC is a system variable to control when the acad.lsp gets loaded. The default setting is set to 0. Setting it to 1, will cause the acad.lsp file to be reloaded each time a drawing is opened during a session.
Create an acad.lsp file using a basic text editor and place it into one of the Support File Search Path locations. Remember it will read the first acad.lsp file it comes to in the list of paths, so one path could be a location on a server that is shared by all users. Since the acad.lsp will run at start-up, you may want to use it to set application based variable, create or load custom shortcut keys and load other custom routines.
Next, is the acaddoc.lsp file. If there is an acaddoc.lsp file found in the Support Search Path when a drawing is opened, it will be loaded each time. The ACADLSPASDOC variable does not apply to the acaddoc.lsp file. This means that this file should most commonly be used to set drawing specific variables. Just like the Acad.lsp, the path list is searched in priority of how they are listed, from top to bottom, so if more than one acaddoc.lsp exist in different path locations, the first one found will be the one that gets loaded.
The acaddoc.lsp file can be created with a basic text editor.
Example of a basic acad.lsp.
(Defun C:C () (command "COPY")(Princ))
(setenv "MaxHatch" "1000000")
(setvar "FILEDIA" 1)
(setvar "ISAVEBAK" 0)
(setvar "LOGFILEMODE" 0)
(setvar "PEDITACCEPT" 1)
(setvar "MAXSORT" 5000)
(setvar "PICKFIRST" 1)
(setvar "XLOADCTL" 0)
(setvar "XREFTYPE" 1)
Example of a basic acaddoc.lsp
S::STARTUP
(command "-scalelistedit" "r" "y" "e")(print)
(command "wscurrent" "3D Basics")
(command "FILEDIA" 1)(print)
(command "UCSFOLLOW" 0)(print)
(command "PLOTOFFSET" 1)(print)
(command "INSUNITS" 0)(print)
(command "UCSICON" "N")(print)
(command "LAYERNOTIFY" 0)(print)
(command "SSMSHEETSTATUS" 1)(print)
(command "MSLTSCALE" 1)(print)
(princ "\nGENERAL VARIABLE SETTINGS loaded!")(print)
The acad.lsp and acaddoc.lsp file are each loaded into memory before the drawing is completely initialized so in order to make sure the command function will work, the function S::STARTUP is included so all the commands after it are called once a new drawing is created or an existing drawing is opened. You may include a definition of S::STARTUP in any LISP file to perform any setup operations. There are limits and setting override possibilities that are not further addressed in this post.
The checkbox for loading ACAD.lsp under the system in the options box, is no longer there since ACAD 20. This is in reference to https://envisioncad.com/autocad-customization-set-system-variables/
As noted in the screenshot, the toggle you mention is just a graphic way to set the ACADLSPASDOC system variable. You can always change this at the command line. In general, there is very little you can’t change from the command line that was part of the original AutoCAD language way back in the 80s. You may not see it anymore, but the commands are mostly there.