0

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

Application.DocumentManager.MdiActiveDocument吗?

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

4

2 回答 2

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

此时,如果您愿意,可以添加终止事件的句柄,如下所示:

Public Sub Terminate() Implements Autodesk.AutoCAD.Runtime.IExtensionApplication.Terminate
    RemoveHandler Application.DocumentManager.DocumentLockModeChanged, subHandler
End Sub
于 2018-09-10T11:54:21.107 回答
1

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

于 2018-09-11T11:02:12.210 回答