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

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

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

Application.DocumentManager.MdiActiveDocument吗?

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

首先你必须删除进口:

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) 然后检查 commandSAVE 还是 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

我致力于使用 CommandEnded 事件而不是 DocumentLockModeChanged。现在它只在保存命令(QSAVe、SAVE、SAVEAS)结束时注册。