Jump to content

Recommended Posts

Posted

Good morning,

 

I was wondering, is it possible to create a list of recently opened / modified files via a LISP?

 

 

Thanks

Posted

Files opened by anything on the computer? or by a specific program? or something else?

Posted

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))))

 

Posted

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

Posted

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

Posted

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")
    )
)

 

  • Like 1
Posted

Fantastic! Thanks, they both work really well.

 

Right, now I am distracted nicely for a Friday afternoon from any real work...

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...