loading lisps

Discussion in 'AutoCAD' started by gregy, Apr 13, 2004.

  1. gregy

    gregy Guest

    What's the best and fastest way to load about 30 lisp routines everytime you enter AutoCAD. Right now I have them in a .vlx and are in my startup suite. That loads pretty slow now as it is growing. Is there a way to load them once they get called for and not before? Or a faster way to load them all?

    Thanks!
     
    gregy, Apr 13, 2004
    #1
  2. There are many ways to accomplish this process.
    This is the method I use and I'm sure the others here will give you other
    methods.

    I use the Acaddoc.lsp file that resides in the "Start In:" folder (from
    AutoCAD Icon/properties) to load my programs.

    Example "Acaddoc.lsp"

    (load "LISP_subrs")
    ;; Thess are my subroutines that are used by multiple defined functions
    (autoload "LISP_Program" (list "UserLisp1" "UserLisp2"))
    ;; This is for a file named LISP_Program.lsp with 2 defined functions
    C:UserLisp1 & C:UserLisp2
    (autoload "FAS_Program.fas" (list "UserLisp3" "UserLisp4"))
    ;; This is for a compiled file named FAS_Program.fas with 2 defined
    functions C:UserLisp3 & C:UserLisp3

    When UserLisp# is issued at the command prompt, then the appropriate program
    is loaded.
     
    Alan Henderson, Apr 13, 2004
    #2
  3. Gregy,

    First, are you SURE you want to penalize your people every thime they start up a
    drawing with such an onerous load process?

    A single VLX will probably load faster than 30 separate (load) calls, if nothing
    else because of less I/O overhead between the user and the server. However, it's
    probably not the most efficient use of time. People may load drawings just to
    view them without the need to load any specialized customization on top.

    Maybe you might try "demand loading" your files individually, such that they
    load only when (and if) you need them. I do this with function libraries.

    For example, suppose you have a LSP file called "MyFunctions.lsp," and the last
    function defined in the file is (f:GetSomething).

    In your acaddoc.lsp or some other LSP file that you will load at startup, define
    these functions:

    (defun init (sym app)
    ;; Test for sym, and if not defined load the app.
    (cond ( (boundp sym))
    ( (= "Nope" (load app "Nope"))
    (prompt (strcat "\nError: " (strcase app) " not loaded."))
    )
    )
    )

    (defun InitMyFunctions ()
    (Init 'fGetSomething "MyFunctions")
    )


    Then, in any routine that relies on that (f:GetSomething) function, put this as
    the first line:

    (defun c:MyApp ()
    (InitMyFunctions)
    (code here...)
    )

    It's really simplistic, and there's the need to error checking, but I know it
    helps me keep all of the extraneous file loading to a minimum.

    Matt

     
    Matt Stachoni, Apr 13, 2004
    #3
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.