EndSave (AutoCAD) is member of what (.net vb)?

136 Views Asked by At

EndSave (AutoCAD) is member of what (.net vb)?

Is it Application.DocumentManager.MdiActiveDocument?

I don't know where it is, so I can add a handler to register its event.

2

There are 2 best solutions below

0
Rita Aguiar On BEST ANSWER

I dediced to use the CommandEnded Event instead of the DocumentLockModeChanged. Now it only register if the save commands (QSAVe, SAVE, SAVEAS) have been ended.

8
Simo On

First you have to delcare the imports:

Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.EditorInput
Imports System.Windows

1) handle he DocumentLockModeChanged event like this:

Public Sub Initialize() Implements Autodesk.AutoCAD.Runtime.IExtensionApplication.Initialize
    Try
        subHandler = New DocumentLockModeChangedEventHandler(AddressOf docChange)
        AddHandler Application.DocumentManager.DocumentLockModeChanged, subHandler
    Catch ex As Exception
        Err.Clear()
    End Try
End Sub

2) and then check if the command is SAVE or SAVEAS:

Implements Autodesk.AutoCAD.Runtime.IExtensionApplication
Dim subHandler As [Delegate]
Public Sub docChange(ByVal sender As Object, ByVal e As DocumentLockModeChangedEventArgs)
    If e.GlobalCommandName = "QSAVE" Or e.GlobalCommandName = "SAVE" Or e.GlobalCommandName = "SAVEAS" Then   
        Application.ShowAlertDialog("Save has occurred")
    End If
End Sub

At this point if you want, you can add the handle for the terminate event, like this:

Public Sub Terminate() Implements Autodesk.AutoCAD.Runtime.IExtensionApplication.Terminate
    RemoveHandler Application.DocumentManager.DocumentLockModeChanged, subHandler
End Sub