Since AutoCAD’s loading of functions operates with the premise of “last loaded wins” (i.e. if you have 2 utilities loading with the exact same function name, the last one to be loaded will be the one AutoCAD will recognize when executing a utility), it is important to understand a few things about how and where AutoCAD looks for files to load. When you open a new or existing drawing, AutoCAD is pre-programmed to look for certain support files in a certain order.
Autodesk’s “AutoCAD” STARTUP FILE LOADING ORDER:
1) acad2011.lsp (AutoCAD file)
2) acad.lsp (User file – only loaded once at AutoCAD 2011 startup, unless ACADLSPASDOC=1)
3) acad2011doc.lsp (AutoCAD file)
4) acaddoc.lsp (User file)
5) custom.mnl (User file)
6) mymenu.mnl (User file)
7) acad.mnl (loaded when “acad.cuix” is loaded)
8) acetmain.mnl (loaded when acetmain.cuix” is loaded-Express Tools)
9) files in the startup suite
10) S::STARTUP Function (may be defined\re-defined in multiple locations)
NOTE: Anything labeled as a “User File” are not files that you will find out of the box.
The acad.lsp and the acaddoc.lsp files are legacy files that still have a use. The difference between the two (besides load order) is the fact that acad.lsp is designed to run only on the first drawing opened in an AutoCAD session (unless ACADLSPASDOC=1), whereas the acaddoc.lsp is designed to run on every drawing that is opened up in a single drawing session. You must create these files and place them somewhere in your support directory structure (found in AutoCAD in the ToolsàOptions dialog on the “Files” tab). The support directory structure is hierarchical, meaning that if an acaddoc.lsp is found under 2 (or more) of the paths in that list, only the one at the highest path in that list will be used.
The custom.mnl and mymenu.mnl files are used only if you have a custom.cuix or mymenu.cuix menu that you have loading. These files would be a good place to put functions that are specific to your user menus so as to keep the entire menu’s functionality in one place.
The Startup Suite is a classic place for the average user to put a library of LISP routines. It is easy to explain how to do it, and it also falls very close to the end of the list so as to ensure that what the user want to use will get loaded near the end. However, if you are a CAD Admin and have set up company wide commands (maybe in the acaddoc.lsp file) that aren’t working for a specific user, this would be your first place to go to make sure they are not overriding the company command with a personal LISP routine.
Lastly, the S::STARTUP is a function that gets run very last after ALL startup files have been loaded. This is an advanced way to make sure a function gets run after the entire drawing has been initialized (you will find that there are certain tasks that cannot be performed while initialization is happening). However, there are things to consider when using this option and it will take a bit of discussion to explain…for next time.
(Auto loading of .NET utilities will also be discussed in the future)