Hi Luis,
How goes? I decided to study your code a little and have some feedback for
you (and for the benefit of others as well).
(... vl-directory-files ... vl-some ... wcmatch ...)
This portion of your code may get a file you don't want. If there are old
autosave files left over from previous sessions with the same file name, you
may get one of them instead of the one for the active drawing. That is why
I use the savefile system variable.
(... copy ... delete ... rename ... delete ...)
I see yours is better than mine here, as it makes sure that there is at
least one copy at any given point in the process. Mine just deletes the old
and copies the new. I'm not sure though why you have the final delete call,
as the file won't be there since you just renamed it.
(... :vlr-beginsave ...)
I don't think this choice of a trigger would have helped in the OP's stated
situation, because it depends on having done a save. In the situation
(which I have seen more than once) where you've gone too long without saving
(yes, messed up in the first place) and AutoCAD up and disappears taking the
built in autosave with it, then you still don't have any autosave.
I like the :vlr-commandWillStart trigger because this is almost always when
drawing changes will take place. And I put the timer function in mine
because the autosave file won't change more often than that anyway. So it
triggers on every command, but does nothing until the savetime has elapsed.
There is also one issue in mine that was pointed out to me before by Andreas
and will also affect yours. In MDI, if muliple files of the same name are
open, our autosave reactors will only maintain a single backup for the
multiple files based on the file name. I haven't bothered to account for
this in mine because that would be such a rare occasion here. But others
may need to take that into account. I think this would be as simple as
using savefile in place of dwgname for the backup, minding file extensions
or prefixes to avoid naming conflicts.
--
James Allen, EIT
Malicoat-Winslow Engineers, P.C.
Columbia, MO
wrote in message news:4865029@discussion.autodesk.com...
Okay,
Since I am not familiar on how the autosave naming is, I was assuming that
the file is truncated, now for the drawings have open here, appears that
the filename base is kept, please do your own corrections on this.
Here is the latest:
[code]
;; 10:07 AM 6/1/2005 LE
;; 12:45 AM 6/2/05 LE
;; 3:06 PM 6/2/05 LE
;; 9:55 AM 6/3/05 LE
(vl-load-com)
(if (not (vl-file-directory-p "C:\\AUTOSAVE\\"))
(vl-mkdir "C:\\AUTOSAVE\\"))
;; this appears to work on an MDI system
;; open more than one drawing(s) and load the
;; reactor on each of them, to test this
(defun copy_sv$ (reactor params / files file)
(if
(and (setq files
(vl-directory-files (getvar "SAVEFILEPATH") "*.SV$"))
(setq file
(vl-some
(function
(lambda (dwg)
(if
(wcmatch
dwg
(strcat "*"
(vl-filename-base (getvar "DWGNAME"))
"*"))
dwg)))
files)))
(progn
;; make a copy of SV$ file into the c:\\autosave folder
;; as a drawing extension with the OUT_ prefix
(vl-file-copy
(strcat (getvar "SAVEFILEPATH") "\\" file)
(strcat "C:\\AUTOSAVE\\" "OUT_" (getvar "DWGNAME")))
;; delete previous BAK_ file
(vl-file-delete
(strcat "C:\\AUTOSAVE\\" "BAK_" (getvar "DWGNAME")))
;; rename the new OUT_ file with the BAK_ prefix
(vl-file-rename
(strcat "C:\\AUTOSAVE\\" "OUT_" (getvar "DWGNAME"))
(strcat "C:\\AUTOSAVE\\" "BAK_" (getvar "DWGNAME")))
;; delete OUT_ file
(vl-file-delete
(strcat "C:\\AUTOSAVE\\" "OUT_" (getvar "DWGNAME"))))))
(if (not dwg_reactor)
(setq dwg_reactor
(vlr-dwg-reactor nil '((:vlr-beginsave . copy_sv$)))))
(princ)
[/code]