make money

jav online; jav streaming; 1pondo; caribbeancom; heyzo - tokyo hot

Award Winning Design Blog

Auto-Loading AutoCAD LISP Utilities – by Aaron Werning

By on January 5, 2011 in Autodesk, Autoplant, Featured, Programming, Tutorial with 11 Comments

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.

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)

Tags: , , ,

About the Author

About the Author: .


If you enjoyed this article, subscribe now to receive more just like it.

There Are 11 Brilliant Comments

Trackback URL | Comments RSS Feed

  1. Chad says:

    Thanks Aaron, this is extremely helpful!

  2. kfauver says:

    Great post Aaron. The LISP newbie out there will like this tidbit. Thanks for sharing you knowledge with the community. (You can pay me later. lol)

  3. APlant Monkey says:

    Aaron thanks very much. this is invaluable information which is not always easy to find. Looking forward to the next installment.

  4. Brad says:

    Good post Aaron, good information and much needed for the majority of us in the industry.

  5. dave says:

    Thanks, Aaron. Your post is clear and It’s great to see this laid out in a way that makes sense! As Brian said, I am looking forward to your next installment!

  6. Zortar says:

    Great info Aaron! Could you write an article explaining (mapcar ‘(lambda (x) )) for us? Thanks!

  7. R. Robert Bell says:

    I have to disagree with the term “legacy” regarding the Acad/AcadDoc.lsp files. Those files are no more a legacy file than the Acad20xx.lsp or Acad20xxDoc.lsp files. As long as AutoLISP/Visual LISP are supported by AutoCAD those files will never be legacy.

    • Zortar says:

      What I read in Aaron’s post regarding the term “legacy” is more that they are “something from the past” as opposed to “outdated or discontinued”. I think this is an important distinction for many of us admins who have created autoloading procedures for our companies that have existed for a couple of decades going back to the original ACAD.LSP file. With each new release of AutoCAD, new files that affect the initial loading of company routines are introduced and we to decide if we need to merge the “legacy” files with the new ones or ignore the new ones, etc. Knowing this, I think you will understand the importance of the distinction Aaron is making.

  8. cadmandu says:

    Thanks for the post Aaron, hoping there is more tidbits to come from you. As always your sharing of knowledge is appreciated. :o)

  9. Brad says:

    I would like to take issue with the font and some of the capitalization. I’m also not sure on some of the punctuation.

Post a Comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.