Steven P Posted November 22, 2019 Posted November 22, 2019 Good morning, I was wondering, is it possible to create a list of recently opened / modified files via a LISP? Thanks Quote
dlanorh Posted November 22, 2019 Posted November 22, 2019 Files opened by anything on the computer? or by a specific program? or something else? Quote
Tharwat Posted November 22, 2019 Posted November 22, 2019 Hi, If you are referring to drawings with the word files then the answer is yes. eg: (vlax-for doc (vla-get-documents (vlax-get-acad-object)) (princ (strcat "\n" (vla-get-name doc)))) Quote
Steven P Posted November 22, 2019 Author Posted November 22, 2019 Whoops, I should have said, drawing DWG files Thanks Tharwat - that gives me the most recently opened and still opened file (so if I open a file and close it, it will give the file before that which is still open) - that is quite useful but not what I was after today What I was after really (my fault, I didn't explain well enough) was a list of maybe the last 5 or so drawing (dwg) files that I saved similar to the 'recent files list' you get in the 'Files' menu I have a little batch routine (not quite in a state to share it but I am working on it) and thought it would be good to add a button along the lines of "do this to the last 5 drawings" - useful for example to plot a mornings work with one button. I am thinking that if I can get a list of recent drawings, then I should be able to get their properties and saved time / date, filter or sort the list to return just todays (or whenever) to do my batch process. Thanks for your help so far - always appreciated Quote
dlanorh Posted November 22, 2019 Posted November 22, 2019 Try this. Rediscovered when transfering lisps. Reads the relevant registry keys. ;; BlackBox/Renderman (defun RecentFiles () (vl-load-com) ((lambda (key i / val values) (while (/= nil (setq val (vl-registry-read key (strcat "File" (rtos (setq i (1+ i)) 2 0))))) (setq values (cons val values))) (reverse values)) (strcat "HKEY_CURRENT_USER\\" (vlax-product-key) "\\Recent File List\\") 0) ) It is a function so call it using (recentfiles). Not sure if it will work on BricsCAD but could be adapted Quote
Lee Mac Posted November 22, 2019 Posted November 22, 2019 The following will return a list of the last 50 drawings opened, sorted with the most recently opened drawing first: (defun LM:recentfiles ( ) ( (lambda ( reg ) (mapcar 'car (vl-sort (mapcar '(lambda ( x ) (cons (vl-registry-read reg x) (atoi (vl-registry-read reg (strcat "filetime" (substr x 5)))) ) ) (vl-remove-if-not '(lambda ( x ) (wcmatch (strcase x t) "file#*")) (vl-registry-descendents reg "") ) ) '(lambda ( a b ) (> (cdr a) (cdr b))) ) ) ) (strcat "HKEY_CURRENT_USER\\" (vlax-product-key) "\\Recent File List") ) ) 1 Quote
Steven P Posted November 22, 2019 Author Posted November 22, 2019 Fantastic! Thanks, they both work really well. Right, now I am distracted nicely for a Friday afternoon from any real work... Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.