run a lisp when open a drawing

Discussion in 'AutoCAD' started by BenC, Jun 13, 2004.

  1. BenC

    BenC Guest

    Hi all, I need help to run a lisp (or script) whenever I open a drawing and subsequent that follow in the same session. I can load the lisp using 'S:startup' or 'appload', and need to type the command to run this lisp. How can I make it to run automatically when each drawing is opened. Thanks.
     
    BenC, Jun 13, 2004
    #1
  2. BenC

    ECCAD Guest

    Create a new acaddoc.lsp file in your \Program Files\autocad 2002\support folder (or autocad 2004\support).
    This will automatically load your lisp program. It cannot run a 'script' until the file is fully open.
    To load your .lsp file, do:
    (load "c:/mypath/mylisp.lsp")
    (princ)

    Save acaddoc.lsp

    Bob
     
    ECCAD, Jun 13, 2004
    #2
  3. BenC

    ECCAD Guest

    If you want a function to run - when loaded, just do:
    (defun C:myfunction ()
    ....body of function
    )
    (C:myfunction); call the function to run..
    (princ)

    Bob
     
    ECCAD, Jun 13, 2004
    #3
  4. BenC

    David Doane Guest

    I believe that once the program is loaded regardless of how, if you have a
    statement near the end of your S::Startup, such as (c:myprogram) it will run
    as S::Startup is the last element loaded.

    Personally I don't use 'appload' at all. I either have the program defined
    in AcadDoc.lsp or put a loading statement in S::Startup such as (load
    "path\\myprogram") in it. For occasional use I use the autoloader.

    Hope this is what you are looking for.
    --
    Dave D

    and subsequent that follow in the same session. I can load the lisp using
    'S:startup' or 'appload', and need to type the command to run this lisp. How
    can I make it to run automatically when each drawing is opened. Thanks.
     
    David Doane, Jun 13, 2004
    #4
  5. BenC

    David Doane Guest

    Ya' beat me whilst I got sidetracked midstream. : (
     
    David Doane, Jun 13, 2004
    #5
  6. BenC

    BenC Guest

    Got it. Thank you all. Ben.
     
    BenC, Jun 14, 2004
    #6
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.