Automatic Date in the title block?

Is it possible to insert today's date in the title block (for example) and have it automatically update to the current date when the drawing opens? 

Comments

  • Easy enough to add a lisp to on_doc_load.lsp that would get the system date, convert it to readable text, and update the drawing.  If the date is not always at the same location relative to point 0,0,0 I would insert a unique symbol in the title block that could be easily found and that could be used as a reference to locate the text.  I've attached the code I use to update the date in my engineering seal when I plot which uses this method. The code finds all instances of the block "seal" and updates the date. 

     

    (defun c:update_seal (/ selset entity point scale rotation c_date Y M D entity_name counter counter2)

    (defun dxf (1code 1ent) (cdr (assoc 1code 1ent)))
    ; returns the value assigned to a dxf code

    (defun getss (apnt adist) ; gets a selection set using a bounding box
    ; based on the apnt point (x,y) passed, box
    ; bounded by (x-adist,y-adist),(x+adist,y+adist)
    (ssget "c"
    (list (- (car apnt) adist) (- (cadr apnt) adist))
    (list (+ (car apnt) adist) (+ (cadr apnt) adist))
    )
    )

    (setq selset (ssget "_X" (list (cons 0 "INSERT") (cons 2 "SEAL")))) ; get all instances of the AZ seal
    (if selset
    (progn
    (if (null (tblsearch "layer" "paper")) ; be sure the layer exists
    (command "-layer" "make" "paper" "color" 50 "paper" "")
    )
    (setq counter 0
    counter3 0
    )
    (while (< counter (sslength selset)) ; loop through the selection set
    (setq entity (entget (ssname selset counter))) ; get the seal entity
    (setq point (dxf 10 entity)) ; get the seal insertion point
    (setq scale (dxf 41 entity)) ; get the seal scale
    (setq rotation (dxf 50 entity)) ; get the seal rotation
    (setq point (polar point ; calc the date insertion point
    (+ rotation 4.868147890)
    (* scale 0.222112991)
    )
    )
    (setq c_date (rtos (getvar "cdate") 2 0)) ; get the system date
    (setq Y (substr c_date 3 2) ; break the date down
    M (substr c_date 5 2)
    D (substr c_date 7 2)
    )
    (setq c_date (strcat M "-" D "-" Y)) ; set to the correct format
    (if (setq selset2 (getss point (* (getvar "dimscale") 0.03))) ; get old date if there is one
    (progn
    (setq counter2 0)
    (while (< counter2 (sslength selset2))
    (setq entity_name (ssname selset2 counter2))
    ; get the old date's entity's name
    (setq entity (entget entity_name))
    ; get the old date's data
    (if (and (= (dxf 0 entity) "TEXT")
    ; looking for date string
    (or (wcmatch (dxf 1 entity) "#-##-##")
    (wcmatch (dxf 1 entity) "##-##-##")
    )
    )
    (progn
    (entdel entity_name)
    )
    )
    (setq counter2 (1+ counter2))
    )
    )
    )
    (entmake (list
    (cons 0 "TEXT") ; entity type
    (cons 1 c_date) ; string
    (cons 7 "romans") ; font / style
    (cons 8 "paper") ; layer
    (cons 10 point) ; insertion point
    (cons 11 point) ; dummy point
    (cons 40 (* (getvar "dimscale") 0.0875)) ; text height
    (cons 41 0.75) ; text width
    (cons 50 rotation) ; rotation
    (cons 62 2) ; color
    (cons 72 1) ; horizontal - center
    (cons 73 2) ; vertical - middle
    (cons 410 "Model")
    )
    )
    (setq counter (1+ counter))
    (setq counter3 (1+ counter3))
    )
    )
    )
    (if (> counter 3 0)
    (if (> counter3 1)
    (print
    (strcat (itoa counter3) "Multiple seals were updated")
    )
    (print "One seal was updated")
    )
    (print "No seal was found")
    )
    (princ)
    )
  • Another way is to use fields. Assuming the title block is an insert with attributes:
    Edit the appropriate attribute and in the value input box right click and choose Insert Field.

  • Yep use a field in an attribute, I use this first one as a plot stamp, the second will get you the current date

    %<\AcVar PlotDate \f "dd.MM.yyyy">%

    %<\AcVar Date \f "dd/MM/yyyy">%

This discussion has been closed.