Execute routine or script before closing AutoCAD

Discussion in 'AutoCAD' started by Rich Sellers, Dec 22, 2003.

  1. Rich Sellers

    Rich Sellers Guest

    I have a small basic package of AutoLisp tools I created and use, as do a
    number of my co-workers. I use the /p switch and a special shortcut to
    start AutoCAD with the proper profile.

    Another set of tools (VBA tools) that we use "assumes" that it's the only
    system we use and has no profile (although I made one myself). When the VBA
    code starts AutoCAD, it doesn't set a profile...it just uses whatever
    profile AutoCAD happens to default to (the last profile that was used).
    Obviously, the arrogance of the VBA programmer to realize that there may be
    more than the VBA tools in use causes some difficulty. The VBA programmer
    is not willing to change....

    Is there a way I can intercept the "exit" command or have an "ending script"
    that will set the profile back to a profile that has the VBA setup whenever
    the user ends an AutoCAD session that has used my tools and profile??

    Thanks in Advance...
    Rich
     
    Rich Sellers, Dec 22, 2003
    #1
  2. Rich,

    I would suggest using a different mechanism to set the profile.

    This routine can be called like this

    (roam_profile "g:/myprofiles/" (strcase (getvar "loginname")))

    for example.

    This will allow individuals to have their profiles stored on a network and move from machine to machine with them.
    Just load and run it in the s::startup

    Peter Jamtgaard

    (defun ROAM_PROFILE (PROFDIR PROFNAM / PROFARRAY PROFOBJ )
    (vl-load-com)
    (setq PROFOBJ (vla-get-profiles
    (vla-get-preferences
    (vlax-get-acad-object)
    )
    )
    )
    (vla-Getallprofilenames PROFOBJ 'PROFARRAY)
    (setq PROFILES (vlax-safearray->list PROFARRAY))
    (if (member PROFNAM
    (mapcar 'strcase PROFILES)
    )
    (vla-put-ActiveProfile PROFOBJ PROFNAM)
    (progn
    (vla-importprofile PROFOBJ
    PROFNAM
    (strcat PROFDIR PROFNAM ".arg")
    :vlax-true
    )
    (vla-put-ActiveProfile PROFOBJ PROFNAM)
    )
    )
    (princ)
    )
     
    Peter Jamtgaard, Dec 22, 2003
    #2
  3. I'm not lookiing to "roam"...

    I want to make sure that, when I exit an AutoCAD session that has used the "Lisp Tool" profile, the profile is set to "VBA Tools". This way, when the VB Application "autoloads" AutoCAD, the profile that will be used (the last active profile when AutoCAD was ended) will be the "VBA Tools" profile.

    Excel has an "auto_close" function....does AutoCAD have something similar??
     
    Steel.Detailer, Dec 22, 2003
    #3
  4. Rich Sellers

    Doug Broad Guest

    Have you tried the beginclose event? You could change
    the profile, either when you close the drawing or when there
    are no documents left. (use document count )

    The beginclose event could be done in vba or autolisp.


    This way, when the VB Application "autoloads" AutoCAD, the profile that will be used (the last active profile when AutoCAD was
    ended) will be the "VBA Tools" profile.
     
    Doug Broad, Dec 22, 2003
    #4
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.