Auto Run

Discussion in 'AutoCAD' started by XPLODE, Sep 9, 2004.

  1. XPLODE

    XPLODE Guest

    I have read numerous posts on this topic and cannot get them to work for me. I need to run a lisp every time a new drawing opens. I have an acaddoc.lsp that loads some of my routines, however, there is a specific one that I would like to run as well not just load. 2002 AutoCAD w/ Land (if it matters).
    I tried calling the function within the lisp itself and the acaddoc.lsp file but that did not do it. Any help would be greatly appreciated.
    Thanks.
     
    XPLODE, Sep 9, 2004
    #1
  2. XPLODE

    Rudy Tovar Guest

    Use 'startup' function.

    me. I need to run a lisp every time a new drawing opens. I have an
    acaddoc.lsp that loads some of my routines, however, there is a specific one
    that I would like to run as well not just load. 2002 AutoCAD w/ Land (if it
    matters).
    file but that did not do it. Any help would be greatly appreciated.
     
    Rudy Tovar, Sep 9, 2004
    #2
  3. XPLODE

    XPLODE Guest

    Thanks for the reply Mr. Tovar. I tried adding s::startup in my acaddoc.lsp file and could not get it to work. I read several posts on S:startup and have not been able to figure it out. I also added a line in the original lisp to call the function itself after it has been loaded and that did not work. I am trying to run the layerfiltersdelete lisp (that I found in these threads - thank you) upon each drawing I open. A little more help and I might be able to finish the puzzle. thanks!
     
    XPLODE, Sep 9, 2004
    #3
  4. XPLODE

    BillZ Guest

    Don't add the s::startup to the acaddoc.lsp.
    Make a Acad.lsp and do it there.


    Bill
     
    BillZ, Sep 9, 2004
    #4
  5. XPLODE

    BillZ Guest

    And set your ACADLSPASDOC to 1


    Bill
     
    BillZ, Sep 9, 2004
    #5
  6. XPLODE

    Doug Broad Guest

    Bill,
    That wouldn't work unless either he didn't want the stuff
    loaded into each drawing or he had "load acad.lsp into each drawing"
    checked in the options. Having acad.lsp loaded into each
    drawing is OK but discouraged in 2000+.

    XPLODE,
    (defun s::startup ()
    ;;put your load and run instructions here
    )

    s::startup runs after drawing initialization is performed.
     
    Doug Broad, Sep 9, 2004
    #6
  7. XPLODE

    Tom Smith Guest

    Assuming that the lisp still says (defun C:LayerFiltersDelete () ... ) then
    you would call it as (C:LayerFiltersDelete).

    I think you should be able to do this in your acaddoc.lsp as follows:

    (load "LayerFiltersDelete.lsp")
    (C:LayerFiltersDelete)

    I'm not sure why Rudy recommended using (s::startup). One difference between
    it and the acad*.lsp files is that (s::startup) executes after all the menus
    are loaded. It seems to be the last thing to happen in the process of
    opening a drawing. To do it this way, include the following in your
    acxaddoc.lsp:

    (defun s::startup ()
    (load "LayerFiltersDelete.lsp")
    (C:LayerFiltersDelete)
    )

    If an (s::startup) function is defined, it is executed automatically upon
    opening a drawing. It will need to include both loading and running the lisp
    you want.
     
    Tom Smith, Sep 9, 2004
    #7
  8. XPLODE

    BillZ Guest

    R2005:

    Yes,
    Now that I look, my acadlspasdoc is set to 1.

    But...
    My s::startup is in my acad.lsp and it (it meaning s::startup) loads in every drawing.

    Why is that?

    Bill
     
    BillZ, Sep 9, 2004
    #8
  9. XPLODE

    BillZ Guest

    Nevermind,
    Tom just explained it.

    :^)

    Bill
     
    BillZ, Sep 9, 2004
    #9
  10. XPLODE

    Tom Smith Guest

    Don't add the s::startup to the acaddoc.lsp.
    I agree with Doug. This may be your preference, but it's contrary to the
    Acad defaults, and in doing this you're defeating the useful distinction
    between acaddoc.lsp (which by design loads in each drawing) and acad.lsp
    (which by design loads only once in the first drawing opened). I don't know
    why you would want to eliminate that distinction.

    Setting ACADLSPASDOC simply means that acad.lsp loads in every drawing. You
    can already do that by naming the file acaddoc.lsp instead. Leaving
    ACADLSPASDOC=0, the default, allows you to distinguish between the two
    behaviors, and this can be useful.

    I use both files. In acad.lsp I can do things like vl-load-com and arxloads
    which only need to be done once when Acad opens. I also use this for some
    administrative things that I only want done about once a day. In acaddoc.lsp
    I can do things like autoloading lisps, which need to happen in each
    drawing.
     
    Tom Smith, Sep 9, 2004
    #10
  11. XPLODE

    Dan Allen Guest

    One reason for s::startup is if you want to run commands, such as (command
    "_.purge" "block" "a$*" "n") to purge anonymous blocks. Or to undefine
    commands with (command "undefine" "hatch"). You can't use (command) in
    acad.lsp or MNL files.

    Dan
     
    Dan Allen, Sep 10, 2004
    #11
  12. XPLODE

    Rick Keller Guest

    Dan,

    I use (command) in my acaddoc.lsp and it seems to work.

    (COMMAND "VIEWRES" "y" 10000)
    (command "-units" "4" "256" "1" "8" "0.00" "n")
    (command "savetime" "1")
    (command "visretain" "1")
    (COMMAND "REGENAUTO" 1)
    (command "wipeout" "f" "off")
    (command "zoom" "E")

    I use all of these and they seem to work.

    Rick
     
    Rick Keller, Sep 10, 2004
    #12
  13. XPLODE

    Tom Smith Guest

    I use (command) in my acaddoc.lsp and it seems to work.
    Most of these could be accomplished through (setvar <variable> <value>)
    without using the command function. Savetime is kept in the registry rather
    the drawing, so there is no need to set it on startup.

    I haven't tried executing (command) functions in a startup file, and don't
    have time to experiment, so I'm not sure about Dan's remarks. I do recall
    vaguely that some things won't work properly unless they're in a
    (s::startup) function because of the load order. When Acad starts, here's
    the order I see:

    Express Tools
    acad.lsp
    acaddoc.lsp
    acad menu / mnl
    custom partial menu /mnl

    At the time the acad*.lsp files run, menus aren't loaded and the drawing
    environment isn't quite all there yet. A (s::startup) function, if present,
    executes AFTER everything else, which is what you would want. I don't think
    Dan is referring to an absolute rule, but rather a good-practice
    recommendation.

    As a side note, I have never understood the need to set variables or modify
    a drawing every time it opens. In my firm, the standard settings are
    established in the drawing templates or the default profile, and they don't
    change. For archiving, I always leave a drawing zoomed to extents, but while
    in progress, I may leave it zoomed in on an area, as a reminder of "where I
    was" at quitting time. Basically, the way I left the drawing was deliberate,
    and I don't want that changed for me the next time I open it. In the
    unlikely event that I create a drawing with different units settings, for
    instance, it would be because I had a good reason for it in that particular
    file. There are rare occasions when I need to do something for a special
    purpose which has no need to conform to normal production drawing standards.
    However I left the drawing is the way I intended it to be, and I don't want
    it "fixed."

    I've been in a place where I constantly needed to work on other people's
    oddball drawings. In that environment, I ran a lisp on startup which checked
    for -- but did not change -- any unusual variable settings. If found, they
    were listed, so I could decide whether they needed changing. Some things
    (like dim variables) can have strange effects on being changed, so I want do
    this consciously and manually. If the drawing setup is truly odd, it's
    generally better to learn to deal with it as-is rather than try to
    arm-wrestle it into being "my way."
     
    Tom Smith, Sep 10, 2004
    #13
  14. XPLODE

    Rick Keller Guest

    Tom,

    The reason I set the save time is because I am forcing other users from
    changing the savetime to something else.
    I dont want anyone changing the setting. I know it is MAJOR overkill but you
    dont notice the quick saves aside from the echo to the command line.

    I set the others because I got tired of getting client drawings with some of
    the settings the way I do not like them, also I set certain settings per
    user at startup
    example I do not like the lineweights showing up but someone else does so I
    turn it on for him and off for me.

    But thanks for pointing out the command / sysvar relationship I never
    noticed it.

    Rick
     
    Rick Keller, Sep 10, 2004
    #14
  15. XPLODE

    Dan Allen Guest

    Hmm, I've never used acaddoc.lsp, I use MNLs to load lisps for every
    drawing. I haven't retested the command/s::startup rule, but it was required
    back in R14.

    Dan
     
    Dan Allen, Sep 11, 2004
    #15
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.