Autocad Customization – Set System Variables

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.

Autocad Training

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.

Autocad Training

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.

Autocad Training

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.

Eric Gates

Eric Gates

Eric joined the EnvisionCAD team in March 2012. He provides Civil3D and Autodesk Infrastructure software consulting, management and production assistance. He has specialized in the Autodesk Infrastructure software Civil 3D and provides expertise in the configuration, development, implementation, management, and custom workflow integrations for the software. Eric’s education concentration has been in design technologies. As a Civil CAD Manager, he led the designing and implementing of all of the CADD software procedures and standards, including preparing teaching materials and training all in-house engineering staff Autodesk software up through AutoCAD 2012 and Civil 3D. As a Civil Designer, he has an excellent grasp of three dimensions and strives to understand each project as a whole and as a sum of parts. Eric has nearly two decades of experience in the development and management of data for civil engineering design and construction projects ranging from roadway development, urban infrastructure, to oil and mining sites and facilities.

Tags: ,

Leave a Reply

Your email address will not be published. Required fields are marked *