Sunday, August 26, 2012

Custom acad.lsp and acaddoc.lsp

We have talked about several methods to load custom content in previous posts. One of my favorites is loading an enterprise cui which in turn will load an mnl file with the same file name. This is a clean method and keeps all of your custom content organized and easily deployed from a central network location. However, there may be times when you really do not have a user interface (cui) and you just want your custom routine(s) to be loaded. There is a handy built in AutoCAD method for this, the acad.lsp and the acaddoc.lsp.

The acad.lsp is a special routine recognized by AutoCAD and is loaded every time an AutoCAD session is launched. The acaddoc.lsp is a special routine recognized by AutoCAD and is loaded every time an AutoCAD drawing is opened.

We can take advantage of these auto-loading routines to load custom content by placing files named either acad.lsp or acaddoc.lsp in any of our support paths defined by our network based profile. Creating separate (custom) acad.lsp and/or acaddoc.lsp files does not interfere with the delivered AutoCAD files (they just need to be in different folders).

For example, in our AutoCAD profile we have a support path defined (C:\sld):

This could of course be any network path. Let's place a custom acaddoc.lsp file that loads some custom content in this folder.

Now when AutoCAD is launched in a profile where our above path is a support path our custom lisp content is loaded.

Note, since we used acaddoc.lsp our routine will load every time a drawing is opened. If we only want our routine to load when AutoCAD is launched we would change the filename to acad.lsp.

I am not sure if there are other default filenames that behave similarly but the above two work great and should provide as much flexibility as you would need. This does not work for .dll files directly however, if you have a custom .dll you can just place a NETLOAD statement inside your custom acad.lsp or acaddoc.lsp. Remember, once you have an access point to load one routine, you can load as many other lisp routines, .dll files, .arx files, and more that you need.

This approach provides another streamlined method to load and manage custom content for multiple users.



No comments:

Post a Comment