EndSave(AutoCAD)是什么(.net vb)的成员?

时间:2018-09-10 10:23:14

标签: .net vb.net autocad addhandler

EndSave(AutoCAD)是什么(.net vb)的成员?

Application.DocumentManager.MdiActiveDocument吗?

我不知道它在哪里,所以我可以添加一个处理程序来注册其事件。

2 个答案:

答案 0 :(得分:1)

首先,您必须对进口商品进行转保:

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

1)像这样处理他的DocumentLockModeChanged事件:

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),然后检查command SAVE 还是 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

此时,如果需要,您可以添加 terminate 事件的句柄,如下所示:

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

答案 1 :(得分:1)

我致力于使用CommandEnded事件而不是DocumentLockModeChanged。现在,仅当保存命令(QSAVe,SAVE,SAVEAS)已结束时才注册。