Date

Discussion in 'AutoCAD' started by brownnoodle, Sep 10, 2004.

  1. brownnoodle

    brownnoodle Guest

    DOES ANYONE KNOW OF LISP PROGRAM THAT CHANGES TEXT INTO (MONTH/DAY/YEAR)?
     
    brownnoodle, Sep 10, 2004
    #1
  2. brownnoodle

    BillZ Guest

    Command: (setq month (substr (rtos (getvar "cdate") 2) 5 2))
    "09"

    Command: (setq day (substr (rtos (getvar "cdate") 2) 1 4))
    "2004"

    Command:(setq year (substr (rtos (getvar "cdate") 2) 7 2))
    "10"

    (setq today (strcat month "/" day "/" year))


    Bill
     
    BillZ, Sep 10, 2004
    #2
  3. brownnoodle

    brownnoodle Guest

    Thanks,
    I'm new to lisp, how do I get this to work?
     
    brownnoodle, Sep 10, 2004
    #3
  4. brownnoodle

    Jürg Menzi Guest

    Hi brownnoodle

    If you wish to convert the system variable 'DATE' into an readable form,
    use this function:
    Code:
    ;
    ; -- Function ConvJulianDate
    ; Convert julian date/time (also serial) to standard format.
    ; Arguments [Typ]:
    ;   Val = Julian date/time [REAL]
    ;   Mde = Conversion mode, eg. "MO/DD/YYYY H:MMam/pm" [STR] *)
    ; Return [Typ]:
    ;   > Formatted date/time [STR]
    ; Notes:
    ;   *) Details for conversion mode see Diesel, edtime
    ;
    (defun ConvJulianDate (Val Mde / TmpVal)
    (setq TmpVal (if (minusp (- Val 2415019.0)) (+ Val 2415019.0) Val))
    (menucmd (strcat "M=$(edtime," (rtos TmpVal) "," Mde ")"))
    )
    
    Use it like:
    (ConvJulianDate (getvar "DATE") "MO/DD/YYYY")
    "09/10/2004"

    Cheers
     
    Jürg Menzi, Sep 10, 2004
    #4
  5. brownnoodle

    BillZ Guest

    how do I get this to work? <<<


    What are you trying to do?


    Bill
     
    BillZ, Sep 10, 2004
    #5
  6. If you want to select an existing piece of text and have its contents
    changed to the current date, you can do this on a toolbar/screen/tablet menu
    item:

    [Up-Date]^C^C^P (setq datetext (entsel "Select Date Text: ")) \(setq
    dateassoc (entget (car datetext))) +
    (setq datestr (substr (rtos (getvar "CDATE") 2) 3 6)) (setq datetx (strcat
    (substr datestr 3 2) "/" (substr datestr 5) "/" (substr datestr 1 2))) +
    (setq dateassoc (subst (cons 1 datetx) (assoc 1 dateassoc) dateassoc))
    (entmod dateassoc) ^P

    That only uses the last two digits of the year. If you want all four, do it
    this way:

    [Up-Date]^C^C^P (setq datetext (entsel "Select Date Text: ")) \(setq
    dateassoc (entget (car datetext))) +
    (setq datestr (substr (rtos (getvar "CDATE") 2) 1 8)) (setq datetx (strcat
    (substr datestr 5 2) "/" (substr datestr 7) "/" (substr datestr 1 4))) +
    (setq dateassoc (subst (cons 1 datetx) (assoc 1 dateassoc) dateassoc))
    (entmod dateassoc) ^P

    Kent Cooper, AIA


    ...
     
    Kent Cooper, AIA, Sep 10, 2004
    #6
  7. Oh, and put the longer lines back together that the newsgroup system has
    split apart (up to the plus signs)....

    Kent Cooper, AIA
     
    Kent Cooper, AIA, Sep 10, 2004
    #7
  8. brownnoodle

    brownnoodle Guest

    I save it as a lisp file. Load the lisp but it doesn't work. I'm using 2002 if that makes a difference.
    I'm looking for a faster way to change the dates on my drawing.
     
    brownnoodle, Sep 10, 2004
    #8
  9. brownnoodle

    brownnoodle Guest

    Thanks,
    Is there a way to have something like this September 10, 2004?
     
    brownnoodle, Sep 10, 2004
    #9
  10. brownnoodle

    GaryDF Guest

    This will give you something to play with:

    (defun ARCH:C_DATE-ISSUE (j / y d m)
    (setq j (fix j)
    j (- j 1721119.0)
    y (fix (/ (1- (* 4 j)) 146097.0))
    j (- (* j 4.0) 1.0 (* 146097.0 y))
    d (fix (/ j 4.0))
    j (fix (/ (+ (* 4.0 d) 3.0) 1461.0))
    d (- (+ (* 4.0 d) 3.0) (* 1461.0 j))
    d (fix (/ (+ d 4.0) 4.0))
    m (fix (/ (- (* 5.0 d) 3) 153.0))
    d (- (* 5.0 d) 3.0 (* 153.0 m))
    d (fix (/ (+ d 5.0) 5.0))
    y (+ (* 100.0 y) j)
    )
    (if (< m 10.0)
    (setq m (+ m 3))
    (setq m (- m 9)
    y (1+ y)
    )
    )
    (strcat (if (< D 10)
    "0"
    ""
    )
    (itoa (fix D))
    " "
    (nth (1- (fix m))
    (list "Jan" "Feb" "March" "April" "May"
    "June" "July" "Aug" "Sept" "Oct"
    "Nov" "Dec"
    )
    )
    " "
    (substr (itoa (fix Y)) 3 2)
    )
    )
    (ARCH:C_DATE-ISSUE (getvar "TDUCREATE"))


    Gary
     
    GaryDF, Sep 10, 2004
    #10
  11. brownnoodle

    Juerg Menzi Guest

    Hi brownnoodle

    (ConvJulianDate (getvar "DATE") "MONTH DD\",\" YYYY")
    "September 12, 2004"

    Cheers
     
    Juerg Menzi, Sep 12, 2004
    #11
  12. brownnoodle

    BillZ Guest

    Ahh...

    (defun mdy (/ day month year)
    (setq month (substr (rtos (getvar "cdate") 2) 5 2)
    day (substr (rtos (getvar "cdate") 2) 1 4)
    year (substr (rtos (getvar "cdate") 2) 7 2)
    today (strcat month "/" day "/" year)
    )
    ) ;end defun


    Bill
     
    BillZ, Sep 13, 2004
    #12
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.