Date Format in Lisp Help

Date Format in Lisp Help

Anonymous
Not applicable
2,488 Views
8 Replies
Message 1 of 9

Date Format in Lisp Help

Anonymous
Not applicable

We are working on a lisp that will fill in some DWGPROPS with one key command. We have it working so typing the command "Approve" will fill in the Author, Subject, and Keyword of the DWGPROPS. For us the Keyword is the date the command is executed. What we can't get is the format of the date within this lisp to be MM/DD/YYYY. We have seen several forum posts for formatting the date, but have been unsuccessful in adding it to this lisp to get it functioning properly. Any help would be greatly appreciated.

 

Lisp is:

(defun C:APPROVE (/ App Doc DwgProps)
(setq App (vlax-Get-Acad-Object)
Doc (vla-Get-ActiveDocument App)
DwgProps (vla-Get-SummaryInfo Doc)
)
(vla-Put-Author DwgProps "COMPANY")
(vla-Put-Subject DwgProps "APPROVED FOR CONSTRUCTION")
(vla-Put-Keywords DwgProps (rtos (getvar 'cdate) 2 0))
(princ (vla-Get-Author DwgProps))(princ", ")
(princ (vla-Get-Subject DwgProps))(princ", ")
(princ (vla-Get-Keywords DwgProps))(princ", ")
(princ (vla-Get-RevisionNumber DwgProps))(princ", ")
(princ (vla-Get-Title DwgProps))(princ", ")
(princ (vla-Get-Comments DwgProps))(princ", ")
(princ)
)

0 Likes
Accepted solutions (1)
2,489 Views
8 Replies
Replies (8)
Message 2 of 9

ronjonp
Mentor
Mentor

Try this:

 

(menucmd "M=$(edtime, $(getvar,date),MM/DD/YYYY)")

 

0 Likes
Message 3 of 9

hak_vz
Advisor
Advisor
(defun cdate ( / date yyyy mm dd)
  (setq date (rtos (getvar "cdate") 2 6))
  (setq yyyy (substr date 1 4)
        mm    (substr date 5 2)
        dd    (substr date 7 2)
  )
    (strcat dd "/" mm "/" yyyy)
 )
;usage (cdate)  returns 28/07/2021

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 4 of 9

Anonymous
Not applicable

In which line would this string go?

0 Likes
Message 5 of 9

Anonymous
Not applicable

Where in our lisp would this go?

0 Likes
Message 6 of 9

ronjonp
Mentor
Mentor
Accepted solution

@Anonymous wrote:

In which line would this string go?


Based on your example above it would be in the 'keywords' section.

(vla-put-keywords dwgprops (menucmd "M=$(edtime, $(getvar,date),MO/DD/YYYY)"))

 

0 Likes
Message 7 of 9

hak_vz
Advisor
Advisor

 

(vla-Put-Keywords DwgProps (cdate))

Or in complete code

(defun C:APPROVE (/ App Doc DwgProps cdate)
(defun cdate ( / date yyyy mm dd)
  (setq date (rtos (getvar "cdate") 2 6))
  (setq yyyy (substr date 1 4)
        mm    (substr date 5 2)
        dd    (substr date 7 2)
  )
    (strcat dd "/" mm "/" yyyy)
 )
 
(setq App (vlax-Get-Acad-Object)
Doc (vla-Get-ActiveDocument App)
DwgProps (vla-Get-SummaryInfo Doc)
)
(vla-Put-Author DwgProps "COMPANY")
(vla-Put-Subject DwgProps "APPROVED FOR CONSTRUCTION")
(vla-Put-Keywords DwgProps (cdate))
(princ (vla-Get-Author DwgProps))(princ", ")
(princ (vla-Get-Subject DwgProps))(princ", ")
(princ (vla-Get-Keywords DwgProps))(princ", ")
(princ (vla-Get-RevisionNumber DwgProps))(princ", ")
(princ (vla-Get-Title DwgProps))(princ", ")
(princ (vla-Get-Comments DwgProps))(princ", ")
(princ)
)

 

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 8 of 9

zainshah44
Explorer
Explorer

SIR MY AUTOCAD .VLX LISP COMMAND FORMATE CHNGE TO NOTEPAD PLS TELL ME HOW CAN I SOLVE THIS ISSUE

 

 

0 Likes
Message 9 of 9

Sea-Haven
Mentor
Mentor

You can not edit a VLX. Need to contact the original author.

0 Likes