donat768 Posted October 26, 2022 Posted October 26, 2022 Hi! I have this code that i found here in the forum it was created by @rlx. My question is how to add an automatic current date and time to the end of the file when im saving it. Many thanks! xoxo (defun c:foo (/ _dir F NF P SF SH) (defun _dir (msg path / sh folder out) (or (vl-file-directory-p path) (setq path (getvar 'dwgprefix))) (cond ((and (setq sh (vlax-get-or-create-object "Shell.Application")) (setq folder (vlax-invoke-method sh 'browseforfolder 0 msg "&H2000" path)) ) (setq out (vlax-get-property (vlax-get-property folder 'self) 'path)) (setq out (strcat (vl-string-right-trim "\\" out) "\\")) ) ) (and sh (vlax-release-object sh)) out ) (if (setq p (_dir "Pick a directory yo!" "E:\\Autocad Files\\SSC\\North Region\\SNE\\")) (progn (setq f (getvar 'dwgname)) (setq sf "Plans") (setq nf (strcat p sf "\\" f)) (cond ((cond ((findfile nf) (print "File exists...") nil) ((vl-file-directory-p (strcat p sf)) (vl-file-copy (strcat (getvar 'dwgprefix) f) nf) t) ((vl-mkdir (strcat p sf)) (vl-file-copy (strcat (getvar 'dwgprefix) f) nf) t) ) (setq sh (vlax-get-or-create-object "Shell.Application")) (vlax-invoke-method sh 'open nf) (vlax-release-object sh) ) ) ) ) (princ) ) (vl-load-com) Quote
tombu Posted October 26, 2022 Posted October 26, 2022 (edited) (rtos (getvar 'cdate) 2 0) Edited October 26, 2022 by tombu had an extra ' 1 Quote
mhupp Posted October 26, 2022 Posted October 26, 2022 (edited) This is what I use (menucmd "M=$(edtime, $(getvar,date),DD-MO-YYYY - HH:MM:SS AM/PM)") --edit For file name replaced the / with - in the date so it won't error Edited October 26, 2022 by mhupp 1 Quote
tombu Posted October 26, 2022 Posted October 26, 2022 I have a field %<\AcVar SaveDate \f "M/d/yyyy">% with Date all my drawing are saved in all my title blocks. While I've never added the date to a file name I'd probably keep it as short as possible if I had to. The 20 in 2022 shouldn't matter for anyone doing cad now in their lifetime so I'd cut that off as well. Quote
ronjonp Posted October 26, 2022 Posted October 26, 2022 (edited) 21 minutes ago, tombu said: I have a field %<\AcVar SaveDate \f "M/d/yyyy">% with Date all my drawing are saved in all my title blocks. Same here With a bit more info: "File: %<\\AcVar Filename \\f \"%tc3%fn7\">% printed by %<\\AcVar Login>% on %<\\AcVar PlotDate \\f \"M/d/yyyy h:mm:ss tt\">% using AutoCAD Version: %<\\AcVar acadver>%" Edited October 26, 2022 by ronjonp 1 Quote
ronjonp Posted October 26, 2022 Posted October 26, 2022 46 minutes ago, mhupp said: (menucmd "M=$(edtime, $(getvar,date),DD-MO-YYYY - HH:MM:SS AM/PM)") @mhupp No need for AM/PM, the results are returned in military time. Quote
donat768 Posted October 27, 2022 Author Posted October 27, 2022 Thanks! I am very new to LISP can someone help me where to put the "(menucmd "M=$(edtime, $(getvar,date),DD-MO-YYYY - HH:MM:SS AM/PM)")"? Do i need to assign it to a variable and then strcat them or how? THANKS Quote
mhupp Posted October 27, 2022 Posted October 27, 2022 2 hours ago, donat768 said: Thanks! I am very new to LISP can someone help me where to put the "(menucmd "M=$(edtime, $(getvar,date),DD-MO-YYYY - HH:MM:SS AM/PM)")"? Do i need to assign it to a variable and then strcat them or how? THANKS UPDATE LINE (setq nf (strcat p sf "\\" f)) TO (setq nf (strcat p sf "\\" (menucmd "M=$(edtime, $(getvar,date),DD-MO-YYYY - HH:MM:SS AM/PM)") "-" f)) 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.