Insert this code into a standard module:
Option Explicit
Sub AddTimeAndDate()
' This example creates a text object in model space.
Dim DateTimeInfo As AcadText
Dim insertionPoint(0 To 2) As Double
Dim height As Double
' Define the text object "insertion point"
'the insertion point is set at 2,2,0 (x, y, z)you can change
'the insertion point to any point on your drawing.
insertionPoint(0) = 2: insertionPoint(1) = 2: insertionPoint(2) = 0
'set text height with respect to dimscale for those of us old timers that still use it
height = 0.5 * ThisDrawing.GetVariable("DIMSCALE")
' Create the text object in model space
Set DateTimeInfo = ThisDrawing.ModelSpace.AddText(Time & " " & Date, insertionPoint, height)
ZoomAll
'regen the active document to make acad update the screen
ActiveDocument.Regen acActiveViewport
Set DateTimeInfo = Nothing
End Sub
|