@rosader ,
Here are my functions for accessing Custom Drawing Properties:
;; key - string, representing key value of custom dwgprop to search for
;; returns - string, of dwgprop value if found, or nil
(defun CDP-Get (key / docProps return)
(setq docProps (vla-get-SummaryInfo (vla-get-ActiveDocument (vlax-get-acad-object))))
(vl-catch-all-apply 'vla-GetCustomByKey (list docProps key 'return))
return
);defun
;; key - string, representing key value of custom dwgprop to search for
;; val - string, representing custom value to be used for the "key" custom dwgprop
;; returns - string, the string provided to "val" parameter if successful, otherwise nil
(defun CDP-Set (key val / docProps)
(setq docProps (vla-get-SummaryInfo (vla-get-ActiveDocument (vlax-get-acad-object))))
(if (not (vl-catch-all-apply 'vla-SetCustomByKey (list docProps key val)))
val
);if
);defun
;; Retrieves all Custom Drawing Properties for current drawing.
;; returns - list, as ((key . value) ...) of all custom drawing properties if any, or nil
(defun CDP-List ( / docProps cnt key val return)
(setq docProps (vla-get-SummaryInfo (vla-get-ActiveDocument (vlax-get-acad-object))))
(repeat (setq cnt (vla-NumCustomInfo docProps))
(vla-GetCustomByIndex docProps (setq cnt (1- cnt)) 'key 'val)
(setq return (cons (cons key val) return))
);repeat
);defun
To Format the date, you can use this function:
(defun today ( / date months)
(setq date (rtos (getvar 'CDATE) 2 0))
(setq months '(
("01" . "JAN") ("02" . "FEB") ("03" . "MAR")
("04" . "APR") ("05" . "MAY") ("06" . "JUN")
("07" . "JUL") ("08" . "AUG") ("09" . "SEP")
("10" . "OCT") ("11" . "NOV") ("12" . "DEC")
))
(strcat
(cdr (assoc (substr date 5 2) months)) " "
(substr date 7 2) ", "
(substr date 1 4)
);strcat
);defun
I've also been working on a useful AutoLISP AI bot that can hopefully return better results than normal ChatGPT (though still needs work, couldn't exactly answer your task proficiently). You can access it from this link if you use the paid version of ChatGPT:
https://chat.openai.com/g/g-Zt0xFNpOH-autolisp-ace
Best,
~DD