AutoCAD

Insert time/date stamp into drawing

Ease of Use

Easy

Version tested with

2004 

Submitted by:

lucas

Description:

This macro will insert a time and date stamp into the current drawing. 

Discussion:

It is often very important to know when a drawing was created, changed, approved, issued, etc. This script will make it easy to insert a date and time into your drawings to a predefined height. 

Code:

instructions for use

			

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

How to use:

  1. Copy the AddTimeAndDate.dvb file to a permanent location on your hard drive. You may wish to set up a directory for your vba routines under your ACAD installation directory. I have one directory for VBA and one for Lisp routines.
  2. Open any CAD File
  3. Click on Tools on the main menubar and from the selections click on Load Application.
  4. You are now looking at the Load/Unload Applications dialog box
  5. In the top window browse to the location where you put your AddTimeAndDate.dvb file and select it. Click the Load button that is located just below the window.
  6. At the bottom of the dialog box You will get a message saying "AddTimeAndDate.dvb loaded successfully"
  7. Click on the close button.
  8. Note: If you wish to view the code or alter it go to tools on the main menu click on macro then click on Visual Basic editor. You can insert a module here and paste the code in manually if you want to.
 

Test the code:

  1. Go back to the main tools menu and click on Macro then on Macro's
  2. In the Macros dialog box You will see The file path-Name of your file(AddTimeAndDate.dvb ) followed by the module name.
  3. Highlight the line described above and click the Run button.
  4. Your computers current date and time will be inserted into your drawing at the points 2 on the x axis and 2 on the y axis.
 

Sample File:

AddTimeAndDate.zip 5.69KB 

Approved by mdmackillop


This entry has been viewed 75 times.

Please read our Legal Information and Privacy Policy
Copyright @2004 - 2020 VBA Express