(progn
(command "_.qsave")
(command "_.save" (strcat (getvar "dwgprefix") (vl-filename-base (getvar "dwgname")) "-Bak.dwg"))
)
This will save the current file, both to the name you want, and a back up one, and will leave you in the real drawing.
Nice one! ^^ :-)Thanks! Learned that trick (using the save command that way) over on the Adesk Ng awhile back, and never have forgotten it.
Perfectly marvelous....except upon the second use the user is promted y/n to overwrite the DWGNAMEBAK file. Can this be set to Yes, to work without the user being prompted?I just saw that, so I think we should make it it's own function.
(defun c:SaveMyA** (/ NewPath)
(setq NewPath (strcat (getvar "dwgprefix") (vl-filename-base (getvar "dwgname")) "-Bak.dwg"))
(command "_.qsave")
(if (findfile NewPath)
(command "_.save" NewPath "_yes")
(command "_.save" NewPath)
)
(princ)
)
I thank you Tim . . . I am thinking about naming thebutton SaveMyA**You're very much welcomed, and thanks for a name for the function. :-D
if I remember use (setvar "expert" 2) - but wait for master Tim....Looks around..... No master Tim I see... :-)
ok, the official name is SaveMyA**,If you just want it in a button, then no need to name it, but use this code instead.
only now that code doesn't work in the button....what did we break?
(progn
(setq NewPath (strcat (getvar "dwgprefix") (vl-filename-base (getvar "dwgname")) "-Bak.dwg"))
(command "_.qsave")
(if (findfile NewPath)
(command "_.save" NewPath "_yes")
(command "_.save" NewPath)
)
(setq NewPath nil)
)
_.qsaveLooks like it worked to me? Did it not save it?
Command: _.save Save drawing as <C:\Civil 3D Projects\UEP SW 6 and 7\Sample
Surface Model.dwg>: C:\Civil 3D Projects\UEP SW 6 and 7\Sample Surface
Model-Bak.dwg A drawing with this name already exists.
Do you want to replace it? <N> _yes
Command: nil
it may look like it 'worked', the thing is it doesn't work with the first click on the button.Glad you got it to work. I'm glad I was able to help out a couple of Civil people. :lmao:
one must click twice or hit return.....so I added an additional RETURN at the end and now it works with a single click. A minor quibble to be sure; but we are very gratefull and totally happy!
As now it is a simple one-click operation and much more likely to be used by the user to save them from the Recovery Manager failing to manage to recover the file.
The Civil 3D world will forever be in your debt!
(progn
(command "_.qsave")
(command "_.save" (strcat (getvar "dwgprefix") (vl-filename-base (getvar "dwgname")) "-Bak.dwg"))
(if (getvar "CMDACTIVE") 0)
(command "_yes")
)
(princ)
)
it may look like it 'worked', the thing is it doesn't work with the first click on the button.
one must click twice or hit return.....so I added an additional RETURN at the end and now it works with a single click. A minor quibble to be sure; but we are very gratefull and totally happy!
As now it is a simple one-click operation and much more likely to be used by the user to save them from the Recovery Manager failing to manage to recover the file.
The Civil 3D world will forever be in your debt!
VERY nice work folks. I was wondering if any of you are using Vault? Any implications?We don't here.
John
VERY nice work folks. I was wondering if any of you are using Vault? Any implications?I don't have vault working here although I may run an experiment when / if 2008 is deployed.
John
Thank you, I missed that bit. I can now work the function either way.I don't see why not, because it is using basic core commands, but then again I don't use Civil 3D.
I am still curious if the new command defined via the lisp routine can be safely called as part of a script or in tandem with other routines to perform this save prior to executing certain Civil 3D commands that are still a bit "dicey" and tend to yield a power exit.
. . . but then again I don't use Civil 3D.You can take great comfort in that. Using Civil 3D is kind of like working with a 14 year old son . . . it has incredible power and can make the task at hand much easier and sometimes even possible, but this potential is evenly matched with a full measure of stubbornness, attitude and immaturity that taxes one's patience to its limits.
Speaking of cats ...
What's that smell, did I step in something?
Thank you all for the replies. I understand the concerns with Vault. I too have many wishes & I have had my patience pushed in all kinds of directions... ;)
John
Speaking of cats ...
Say Kerry, how about a brief overview of the who, what, when, where of the code that you posted?
(DEFUN c:nsave ( / dname dpref bdir dbac)
(setq dname (getvar "DWGNAME"))
(setq dpref (getvar "DWGPREFIX"))
(setq bdir (strcat "C:/ACADBACK/" dname))
(command "Qsave")
(setq dbac (vl-file-copy (getvar "savename") bdir))
(if (= dbac nil)
(progn
(vl-file-delete bdir)
(vl-file-copy (getvar "savename") bdir)
)
)
(setq sname (strcat "File Saved To "dpref dname))
(setq sname1 (strcat sname "\nFile Saved To "bdir))
(ALERT sname1 )
;(prompt "\n\nFile Saved...")
;(princ bdir)
;(prompt "\n\nFile Saved...")
;(princ dpref)
;(princ dname)
(princ)
);END QSAVE
I am using this now and it works, however I've noticed on multiple occasions after a save that while I am in the original *.dwg the toolspace shows that the *BAK.dwg file is the one opened. Has anyone else noticed such a glitch?ok, the official name is SaveMyA**,If you just want it in a button, then no need to name it, but use this code instead.
only now that code doesn't work in the button....what did we break?Code: [Select](progn
(setq NewPath (strcat (getvar "dwgprefix") (vl-filename-base (getvar "dwgname")) "-Bak.dwg"))
(command "_.qsave")
(if (findfile NewPath)
(command "_.save" NewPath "_yes")
(command "_.save" NewPath)
)
(setq NewPath nil)
)
I am using this now and it works, however I've noticed on multiple occasions after a save that while I am in the original *.dwg the toolspace shows that the *BAK.dwg file is the one opened. Has anyone else noticed such a glitch?ok, the official name is SaveMyA**,If you just want it in a button, then no need to name it, but use this code instead.
only now that code doesn't work in the button....what did we break?Code: [Select](progn
(setq NewPath (strcat (getvar "dwgprefix") (vl-filename-base (getvar "dwgname")) "-Bak.dwg"))
(command "_.qsave")
(if (findfile NewPath)
(command "_.save" NewPath "_yes")
(command "_.save" NewPath)
)
(setq NewPath nil)
)
Thats because thats the name it was saved as LAST.On my system that doesn't matter. If you use the save command, and give it a name, it will save the file to that name, but keep the original one open still. Maybe there is a system variable or something that is setup different.
(DEFUN c:nsave (/ dname dpref bdir incr)
(setvar "CMDECHO" 0)
(setq dname (vl-filename-base (getvar "DWGNAME")))
(setq dpref (getvar "DWGPREFIX"))
(setq bdir (strcat dpref "DWGBACKUP\\"))
(setq incr (rtos (getvar "CDATE") 2 6))
(if (not (vl-file-directory-p bdir))
(vl-mkdir bdir)
)
(if (findfile (strcat bdir dname "-" incr "-Bak.dwg"))
(vl-cmdf "._save"
(strcat bdir dname "-" incr "-Bak.dwg")
"_Y"
)
(vl-cmdf "._save" (strcat bdir dname "-" incr "-Bak.dwg"))
)
(if (findfile (strcat dpref dname ".dwg"))
(vl-cmdf "._Qsave")
(vl-cmdf "._save" (strcat dpref dname ".dwg"))
)
(princ "\save and backup done !")
(princ)
)
(vl-load-com)
(if (not *rjp-CommandReactors*)
(setq *rjp-CommandReactors*
(vlr-command-reactor
nil
'((:vlr-commandEnded . EndCMD))
)
)
)
(defun EndCMD (calling-reactor EndCMDInfo /)
(if (wcmatch (strcase (nth 0 EndCMDInfo) T) "*save*")
(rjp-backupdwg)
)
)
;;makes a copy a DWG after a save to "C:/AutoCAD-BAK/"...keeps 1/2 hour history
(defun rjp-backupdwg (/ bkupdir date time hour minute dwgpath fullpath dwgdir)
(if (= (getvar 'dwgtitled) 1)
(progn (setq bkupdir "C:/AutoCAD-BAK/";;put the path you want here
date (rtos (fix (getvar 'cdate)) 2 0)
date (strcat (substr date 5 2) "." (substr date 7 2) "." (substr date 1 4) "/")
time (rtos (rem (getvar 'cdate) 1) 2 6)
hour (substr time 3 2)
minute (substr time 5 2)
hour (if (>= (atoi minute) 30)
(strcat hour "-30/")
(strcat hour "/")
)
dwgpath (strcat (vl-string-right-trim
"."
(substr (vl-string-translate "\\\"" "." (getvar 'dwgprefix)) 4)
)
"/"
)
fullpath (strcat bkupdir date hour dwgpath (getvar 'dwgname))
dwgdir (strcat (getvar 'dwgprefix) (getvar 'dwgname))
)
(vl-mkdir bkupdir)
(vl-mkdir (strcat bkupdir date))
(vl-mkdir (strcat bkupdir date hour))
(vl-mkdir (strcat bkupdir date hour dwgpath))
(if (findfile fullpath)
(vl-file-delete fullpath)
)
(vl-file-copy dwgdir fullpath)
)
)
(princ)
)
^C^C(progn
(setq NewPath (strcat (getvar "dwgprefix") (vl-filename-base (getvar "dwgname")) "-Bak.dwg"))
(if (findfile NewPath)
(command "_.save" NewPath "_yes")
(command "_.save" NewPath)
)
(setq NewPath nil)
(command "_.qsave")
)
We seemed to have resolved our problem using the following code.Code: [Select]^C^C(progn
(setq NewPath (strcat (getvar "dwgprefix") (vl-filename-base (getvar "dwgname")) "-Bak.dwg"))
(if (findfile NewPath)
(command "_.save" NewPath "_yes")
(command "_.save" NewPath)
)
(setq NewPath nil)
(command "_.qsave")
)
Thanks for your input.
<edit CAB: added code tags>