See the top rated post in this thread. Click here

Page 1 of 13 1234511 ... LastLast
Results 1 to 10 of 130

Thread: Automatically Open Drawings From Previous Session

  1. #1
    I could stop if I wanted to
    Join Date
    2015-09
    Posts
    420
    Login to Give a bone
    0

    Default Automatically Open Drawings From Previous Session

    Hello To All AUGI Members:

    Is there a way via Autolisp or VBA etc. to run a routine and have AutoCAD remember all of the drawings files a user had open the last time they exited from their AutoCAD session and then when that user starts AutoCAD again run a routine that will automatically open all of those drawing files that were open before...???

  2. #2
    AUGI Addict madcadder's Avatar
    Join Date
    2000-11
    Location
    Too far from the beach
    Posts
    1,054
    Login to Give a bone
    0

    Default Re: Automatically Open Drawings From Previous Session

    Sounds easy enough for someone better skilled than me.

    (part one of lisp)
    The WINDOWS pulldown tracks the open drawings somehow. So the system has that info. (Terry Dotson also retrieved/uses it in RECENT.VLX)
    That info can be saved to a TXT file.

    (part two)
    A second routine reads that TXT file, opens a drawing, removes that drawing from the list and goes to the next until the list is empty.


    Sounds easy enough...

  3. #3
    The Silent Type RobertB's Avatar
    Join Date
    2000-01
    Location
    Seattle WA USA
    Posts
    5,859
    Login to Give a bone
    0

    Talking Re: Automatically Open Drawings From Previous Session

    Please see the attached VBA project. It should be self-explainatory. You simply run the WriteSnapshot macro when you want to record what drawings are loaded (saved to an external text file, location and name can be modified in the code).

    When you start AutoCAD again, if you modified your Acad.lsp as noted in the project's header, the ReadSnapshot is run automatically. If it finds the snapshot, it will load all the drawings it can find.
    Last edited by RobertB; 2005-08-06 at 02:10 AM. Reason: Removed old version of program

  4. #4
    Certifiable AUGI Addict robert.1.hall72202's Avatar
    Join Date
    2004-07
    Location
    Detroit Michigan
    Posts
    2,508
    Login to Give a bone
    0

    Default Re: Automatically Open Drawings From Previous Session

    Sounds great thanks for posting.

    I tried to use the attached file and I am getting the following:

    (vla-RunMacro (vlax-Get-Acad-Object) "WriteSnapshot") ; error:
    Automation Error. Failed to run VBA macro

  5. #5
    AUGI Addict madcadder's Avatar
    Join Date
    2000-11
    Location
    Too far from the beach
    Posts
    1,054
    Login to Give a bone
    0

    Default Re: Automatically Open Drawings From Previous Session

    Mr. Bell, sir, you are awesome.
    I was able to make it run exaclty as described. Had four drawings open, clicked the snapshot button, and closed cad. When I reopened so did the four drawings.

    Two thouhgts:
    1) I noticed that the next session after a session where a snapshot was not taken it does not open the last snapshot that was taken. It defaults to only DRAWING1.
    Was that by design?

    2) I disabled the OPEN dialog box to further automate the loading while testing. Is there a way to automatically close DRAWING1.dwg?

  6. #6
    AUGI Addict madcadder's Avatar
    Join Date
    2000-11
    Location
    Too far from the beach
    Posts
    1,054
    Login to Give a bone
    0

    Default Re: Automatically Open Drawings From Previous Session

    This is the best I can contribute...

    Code:
     ;;; QuikSaveExit.lsp
     (DEFUN c:qse (/)
       (VL-LOAD-COM)
       (VLA-RUNMACRO (VLAX-GET-ACAD-OBJECT) "WriteSnapshot")
       (VLAX-FOR doc	(VLA-GET-DOCUMENTS (VLAX-GET-ACAD-OBJECT))
     	(IF	(AND
     	  (= :VLAX-FALSE (VLA-GET-SAVED doc) (VLA-GET-READONLY doc))
     	)
     	  (PROGN (WRITE-LINE (STRCAT "\nSaving " (VLA-GET-NAME doc)))
     		 (VLA-SAVE doc)
     	  )
     	)
       )
       (COMMAND "_quit")
       (PRINC)
     )
    Toolbar Button:
    Code:
     ID_SaveExit	[_Button("Save and Exit", "saveexit.bmp", "saveexit")]^C^C(if(not c:qse)(load"quiksaveexit"));qse
    and a nice pretty bmp attached.
    Attached Images Attached Images

  7. #7
    The Silent Type RobertB's Avatar
    Join Date
    2000-01
    Location
    Seattle WA USA
    Posts
    5,859
    Login to Give a bone
    0

    Default Re: Automatically Open Drawings From Previous Session

    Quote Originally Posted by todw
    Mr. Bell, sir, you are awesome.
    I was able to make it run exaclty as described. Had four drawings open, clicked the snapshot button, and closed cad. When I reopened so did the four drawings.

    Two thouhgts:
    1) I noticed that the next session after a session where a snapshot was not taken it does not open the last snapshot that was taken. It defaults to only DRAWING1.
    Was that by design?

    2) I disabled the OPEN dialog box to further automate the loading while testing. Is there a way to automatically close DRAWING1.dwg?
    I'm glad you liked it. I thought it was a neat idea.

    #1 Yes, that was intentional. ReadSnapshot deletes the old snapshot file. I figured that having the same drawings opened over more than one session of AutoCAD might indicate that the user was too slow and should be fired.

    Actually, the real reason was that I assumed that a different snapshot was more likely to be desired after starting a new session.

    #2 What happened to you to require changing the Open dialog? I had no such issue here, so I'm curious as to what is different on your end. And, yes, I could do something about Drawing1.

  8. #8
    The Silent Type RobertB's Avatar
    Join Date
    2000-01
    Location
    Seattle WA USA
    Posts
    5,859
    Login to Give a bone
    0

    Default Re: Automatically Open Drawings From Previous Session

    Quote Originally Posted by rhall.72202
    Sounds great thanks for posting.

    I tried to use the attached file and I am getting the following:

    (vla-RunMacro (vlax-Get-Acad-Object) "WriteSnapshot") ; error:
    Automation Error. Failed to run VBA macro
    Did you load the VBA project first? If you made the modifications to the Acad.lsp, and restarted AutoCAD, the LISP statement would work too.

  9. #9
    The Silent Type RobertB's Avatar
    Join Date
    2000-01
    Location
    Seattle WA USA
    Posts
    5,859
    Login to Give a bone
    0

    Default Re: Automatically Open Drawings From Previous Session

    Quote Originally Posted by todw
    This is the best I can contribute...
    I thought about automatically closing AutoCAD with the WriteSnapshot. I'll add that in, along with the close Drawing1 idea.

  10. #10
    AUGI Addict madcadder's Avatar
    Join Date
    2000-11
    Location
    Too far from the beach
    Posts
    1,054
    Login to Give a bone
    0

    Default Re: Automatically Open Drawings From Previous Session

    Quote Originally Posted by RobertB
    #2 What happened to you to require changing the Open dialog? I had no such issue here, so I'm curious as to what is different on your end. And, yes, I could do something about Drawing1.
    No issue. I just wanted to speed load the previous session. With the traditional box I would just hit cancel and all was the same.

    I noticed that it reopens the drawing in the same order that they were originally opened. K.
    Besides adding a closing of Drawing1 upon opening could the current active drawing be trapped by snapshot when and restored upon opening?

    How'd you like the lisp addition?.. modded what I already use to click a button and 'poof' cad 's gone. If you would like, add all this stuff together for a full "session saver" program.
    Last edited by madcadder; 2005-08-05 at 07:08 PM. Reason: edited wording of first sentence.

Page 1 of 13 1234511 ... LastLast

Similar Threads

  1. Replies: 1
    Last Post: 2007-09-19, 03:40 PM
  2. Previous Command Available Across Drawings
    By autocad.wishlist1734 in forum AutoCAD Wish List
    Replies: 0
    Last Post: 2007-05-02, 01:44 PM
  3. Replies: 5
    Last Post: 2006-10-09, 09:25 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •