itacad Posted October 30 Share Posted October 30 Hello, I have seen many solutions to write the current date in a "dynamic" way, that is, it corrects itself every time the file is opened. Instead I was looking for a lisp to write the current date (dd/mm/yyyy) in an attribute in a "static" way, that is, as a simple correction of the text...but I didn't find anything. I also ask if there are key combinations for entering "known" texts for example in excel, the current date can be inserted with ctrl+alt+a Greetings Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted October 30 Share Posted October 30 As a very simple example - (defun c:mydate ( / ent obj ) (while (progn (setvar 'errno 0) (setq ent (car (nentsel))) (cond ( (= 7 (getvar 'errno)) (princ "\nMissed, try again.") ) ( (not (vlax-write-enabled-p (setq obj (vlax-ename->vla-object ent)))) (princ "\nObject is on a locked layer.") ) ( (not (vlax-property-available-p obj 'textstring)) (princ "\nInvalid object selected.") ) ( (vla-put-textstring obj (menucmd "m=$(edtime,0,dd/mo/yyyy)"))) ) ) ) (princ) ) (vl-load-com) (princ) You can change the formatting code to suit. Quote Link to comment Share on other sites More sharing options...
Steven P Posted October 30 Share Posted October 30 I've similar but not as succinct as Lees - only comment I have is I added an option "select text or enter delimitator" to allow for dd/mm/yy, dd-mm-yy, dd.mm.yy, and yy or yyyy etc. formats - clients can be fickle Example for OP for formatting if necessary: (menucmd "m=$(edtime,0,dd-mo-yyyy)")) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted October 31 Share Posted October 31 For reference, the syntax for the edtime DIESEL function may be found here - https://help.autodesk.com/view/ACD/2025/ENU/?guid=GUID-F94A885A-4DA2-432B-AC1A-EB49CC6C1C72 1 Quote Link to comment Share on other sites More sharing options...
X11start Posted October 31 Share Posted October 31 For a long time I have been using a lisp to update the blocks called "DATA" selected in the drawing with the current date. You can use it as a standalone lisp or within another lisp. Running the "DATA" command from the command line: You will be asked for 2 points, the CDATE value will be read and the string DATETIME will be created finally, the attribute containing the date will be updated, but only blocks with the name "DATA" found in the area of the 2 points box. By giving RETURN to the request for the first point, the date is reset: the 2 points will then be requested all selected "DATA" blocks will become equal to: 00/00/00_00:00 Conversely, if the date is to be generated by another lisp (e.g. MYPRINT. LSP), the entry point In this LISP it will be: (x11:DATA pt1 pt2) .... To update to the new date: provide the 2 points PT1 and PT2! My version works both on Autocad and on GSTARCAD: the peculiar thing is that I had to make 2 versions, because with GSTACAD I always got the winter time... so wrong by 1 hour six months a year! DATA.LSP Quote Link to comment Share on other sites More sharing options...
itacad Posted October 31 Author Share Posted October 31 Thank you all for your help! I would like to take this opportunity to thank Mr. Lee Mac, whom I have known by reputation long before discovering this forum! With his lisps he has solved many problems for me! I would like to point out a couple of topics I have opened regarding his lisps that I use daily Thanks! https://www.cadtutor.net/forum/topic/77190-count-attribute-values/ https://www.cadtutor.net/forum/topic/93061-macatt-global-attribute-extractorlayer-information/ Quote Link to comment Share on other sites More sharing options...
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.