Last Opened Files

Last Opened Files

Code_x
Advocate Advocate
601 Views
7 Replies
Message 1 of 8

Last Opened Files

Code_x
Advocate
Advocate

I am looking for a script, LISP, or macro — or any quick method — that allows me to save my previous session in AutoCAD. Ideally, I would like to be able to close AutoCAD or restart my computer, and upon relaunching AutoCAD, be able to restore and reopen all the CAD files that I was working on before closing. Any suggestions or advice would be greatly appreciated.

0 Likes
602 Views
7 Replies
Replies (7)
Message 2 of 8

Moshe-A
Mentor
Mentor

@Code_x  hi,

 

I do not know if there is a solution to such request but i recommend you to give more thoughts about it

heavy files (contain xrefs \ nested xrefs) may have errors (requires RECOVER\AUDIT) may stuck AutoCAD at load (even worth)  AutoLISP \ SCRIPT has no tools to trap such cases.

 

Moshe

 

0 Likes
Message 3 of 8

Code_x
Advocate
Advocate
 

As long as AutoCAD attempts to open the same files, I can handle any errors or recovery issues that come up manually. What’s most important is having a record of what I was working on before shutting down my PC. Ideally, I’d like to run a command that generates a list of file paths for all open drawings, which I can save for future use. This way, I could quickly copy and paste these paths back into AutoCAD to reopen everything at once. Would this be a viable alternative solution?

0 Likes
Message 4 of 8

komondormrex
Mentor
Mentor

output all open documents to the text window

(setq doc_index -1)
(repeat (vla-get-count (setq documents (vla-get-documents (vlax-get-acad-object))))
  (princ (strcat "\n" (vla-get-path (vla-item documents (setq doc_index (1+ doc_index)))) "\\"
			(vla-get-name (vla-item documents doc_index))
	 )
  )
)

 

0 Likes
Message 5 of 8

Sea-Haven
Mentor
Mentor

Could maybe write a script file that has current dwg names, in a "autoload" lisp then call the script. See @komondormrex code. Not sure when you would run the make script.

Eg script

 

 

open dwg1
open dwg2

 

 

0 Likes
Message 6 of 8

ec-cad
Collaborator
Collaborator

In order to 'reload' / 'open' your last session. You would have to 'write' a list of open / active drawings in

the last session. Say with a Lisp called SaveOld.lsp, that would save that info to disk.

And, when you open the Acad session for later, in startup, load a Lisp that checks for the 'data' file, reads

it in, and opens the previous drawings. Could be done. You would only be 'required' to call

the function in SaveOld.lsp to write that info out to disk for the next session.

 

ECCAD

0 Likes
Message 7 of 8

Sea-Haven
Mentor
Mentor

Agree with you @ec-cad only thing needed would be maybe 3 choices, don't always want to open other dwg's may only want to work on a single dwg.

 

SeaHaven_0-1727651001297.png

 

0 Likes
Message 8 of 8

komondormrex
Mentor
Mentor

script + lisp/reactor on command 'quit'.

 

1. in a preferred place make an empty script file with the name 'Last_Session.scr'. add the line "(vl-load-all last_session")" followed by empty string to the created script file and save it.

2. add to the shortcut to the autocad batch switch with the path to the script file like the following

komondormrex_0-1727707034145.png

3. save the attached lisp code as the 'Last_Session.lsp' to a place where autocad could find it and load upon request. replace 'YOUR_PATH' in the code to the real your path where is the script saved.

4. run autocad and open your work files.

5. upon finishing your working with the files click right upper cross or enter command 'quit' to exit autocad. all opened documents will be saved to the script file to be opened next time you launch your autocad program like this.

komondormrex_1-1727707690031.png

 

0 Likes