AfraLISP - Learn AutoLISP for AutoCAD productivity

A Better Autosave

by Kenny Ramage

The Autosave feature in AutoCAD does not save the drawing you are working on, but saves a copy of your drawing to a directory stored in the Savefilepath system variable. This drawing does not have the same name as your drawing file and can be overwritten with subsequent Autosaves. Here's a little VBA application which I wrote that will save your drawings at a user determined interval. (or very close.) It basically takes the time from the system clock and stores it in one of the User system variables. Every time you select "Line," "Pline," or "Zoom," the application checks to see if 15 minutes has passed. If it hasn't, it does nothing. If it has, it saves the drawing and then resets the stored time to the system time.

Stick this coding in a module, save it as "SaveTime.dvb," and add it to your startup suitcase.

'<--Start Coding Here
Option Explicit

Private Sub AcadDocument_BeginCommand(ByVal CommandName As String)

Dim OldTime
Dim NewTime

'trigger when user selects
Case "LINE", "PLINE", "ZOOM"

'get the time now
NewTime = (Hour(Time) * 60) + Minute(Time)

'get the time stored in USERI2
OldTime = ThisDrawing.GetVariable("Useri2")

'If the time has not been set
If OldTime = 0 Then

'set the time
ThisDrawing.SetVariable ("Useri2"), NewTime

'then end
End

End If

'if the difference is greater that 15 minutes
If (NewTime - OldTime) > 15 Then

'save the drawing
ThisDrawing.Save

'and then reset Useri2
ThisDrawing.SetVariable ("Useri2"), NewTime

End If

'end of the Select
End Select

End

End Sub

'End Coding Here-->