Baber62 10 Posted February 4, 2014 Hi, I need a lisp routine to do the following if a new file has not been saved save it as [Filename - Rev 000 - Date - Time] where the user is prompted for a filename. Then after having worked on the drawing subsequently to increment the Rev by 1 and add new date and time. The time should be in the "hh-mm" format. Also when the drawing is being saved it should be saved in two locations one in a superseded folder and one in the current folder. I have managed to create a macro using vba which can do this for an excel spreadsheet just wondering if something similar could be created in lisp for AutoCAD drawings. Quote Share this post Link to post Share on other sites
MSasu 16 Posted February 4, 2014 You can redefine the SAVE command to act in that way. Quote Share this post Link to post Share on other sites
Baber62 10 Posted February 4, 2014 Hi Mircea, any advice on how to do this would be appreciated. Quote Share this post Link to post Share on other sites
MSasu 16 Posted February 4, 2014 A starter: (vl-load-com) (command "_UNDEFINE" "_QSAVE") (defun c:QSave( / stringDate fileName ) (setq stringDate (rtos (getvar "CDATE") 2 6)) (if (eq (getvar "DWGTITLED") 0) ;test if drawing was saved (if (setq fileName (getfiled "Save drawing" (getvar "DWGPREFIX") "DWG" 1)) (command "_.SAVE" (strcat (vl-filename-directory fileName) "\\" (vl-filename-base fileName) "-Rev000-" (substr stringDate 1 "-" (substr stringDate 10 4) (vl-filename-extension fileName))) ) ) (princ) ) ;(command "_REDEFINE" "_QSAVE") ;to get ride later of this change The above function definition should be placed in an auto-loader to be available in all drawings. Quote Share this post Link to post Share on other sites
marko_ribar 70 Posted February 4, 2014 VL-FILENAME-BASE VL-FILENAME-DIRECTORY VL-FILENAME-EXTENSION VL-FILENAME-MKTEMP are (VL-LOAD-COM) independent functions, so you don't need (vl-load-com) line at start of code... M.R. Quote Share this post Link to post Share on other sites
Baber62 10 Posted February 4, 2014 Hi Mircea, Have added the lisp routine to my autocad2011doc.lsp file so it loads up whenever AutoCAD opens up. When I type in the qsave command nothing happpens? Quote Share this post Link to post Share on other sites
MSasu 16 Posted February 4, 2014 Please consider the use of acaddoc.lsp auto-loader; the one you used is reserved for system purposes and isn't recomended to be edited by user. Also, don't miss that my example is for new (not-saved) drawings only and was intended to serve as a starter for your own code. Quote Share this post Link to post Share on other sites
Baber62 10 Posted February 5, 2014 Hi Mircea ... that's where the problem lies, I am not experienced in lisp therefore would appreciate some additional help as to getting this to work. Quote Share this post Link to post Share on other sites
MSasu 16 Posted February 6, 2014 should be saved in two locations one in a superseded folder and one in the current folder. Can you post, please, the path of that backup folder? Quote Share this post Link to post Share on other sites