KevinBarnett
2006-01-27, 08:20 AM
I need to write a program that performs actions at the end of certain commands. To this end I have written the following code. The code should at least message "Kilroy was here" but it doesnt (although, what I really need is name of the command that just ended).
What is missing?
Thx.
Kevin.
Imports System
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.GraphicsInterface
Public Class Class1
Implements Autodesk.AutoCAD.Runtime.IExtensionApplication
Private CurrentDoc As Document
Private Shared Sub m_doc_Commandended(ByVal sender As System.Object, _
ByVal e As Autodesk.AutoCAD.ApplicationServices.CommandEventArgs)
Dim curdb As Database = Application.DocumentManager.MdiActiveDocument.Database
Dim tm As Autodesk.AutoCAD.DatabaseServices.TransactionManager = curdb.TransactionManager
Dim myT As Transaction = tm.StartTransaction()
MsgBox("Kilroy was here")
Try
MsgBox(sender.ToString)
Catch ex As Exception
myT.Abort()
MsgBox(ex.Message.ToString)
Finally
myT.Dispose()
End Try
End Sub
What is missing?
Thx.
Kevin.
Imports System
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.GraphicsInterface
Public Class Class1
Implements Autodesk.AutoCAD.Runtime.IExtensionApplication
Private CurrentDoc As Document
Private Shared Sub m_doc_Commandended(ByVal sender As System.Object, _
ByVal e As Autodesk.AutoCAD.ApplicationServices.CommandEventArgs)
Dim curdb As Database = Application.DocumentManager.MdiActiveDocument.Database
Dim tm As Autodesk.AutoCAD.DatabaseServices.TransactionManager = curdb.TransactionManager
Dim myT As Transaction = tm.StartTransaction()
MsgBox("Kilroy was here")
Try
MsgBox(sender.ToString)
Catch ex As Exception
myT.Abort()
MsgBox(ex.Message.ToString)
Finally
myT.Dispose()
End Try
End Sub