Hello,
I need to Veto ETRANSMIT in some cases, I stripped down my code to a msgbox that will ask if i want to Veto Or not
Imports Autodesk.AutoCAD.Runtime Imports Autodesk.AutoCAD.ApplicationServices <Assembly: ExtensionApplication(GetType(GHATransmit.Initialization))> Namespace GHATransmit Public Class Initialization Implements IExtensionApplication Public KillCommand As Boolean = False Public Sub Initialize() Implements Autodesk.AutoCAD.Runtime.IExtensionApplication.Initialize Dim dm As DocumentCollection = Application.DocumentManager Dim doc As Document = dm.MdiActiveDocument AddHandler doc.CommandWillStart, New CommandEventHandler(AddressOf StartCommand) AddHandler dm.DocumentCreated, New DocumentCollectionEventHandler(AddressOf InstallDoc) AddHandler dm.DocumentLockModeChanged, New DocumentLockModeChangedEventHandler(AddressOf LockModeChanged) End Sub Private Sub InstallDoc() Dim dm As DocumentCollection = Application.DocumentManager Dim doc As Document = dm.MdiActiveDocument AddHandler doc.CommandWillStart, New CommandEventHandler(AddressOf StartCommand) End Sub Private Sub LockModeChanged(ByVal sender As Object, ByVal e As DocumentLockModeChangedEventArgs) If KillCommand Then Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage(vbLf & "VETO MY COMMAND (" & KillCommand & ")") KillCommand = False e.Veto() End If End Sub Public Sub Terminate() Implements Autodesk.AutoCAD.Runtime.IExtensionApplication.Terminate End Sub Private Sub StartCommand(ByVal o As Object, ByVal e As CommandEventArgs) Try Dim oCName = e.GlobalCommandName If oCName = "ETRANSMIT" Then If MsgBox("Do you want to Veto the ETRANSMIT command?", vbYesNo, "?") = vbYes Then KillCommand = True Else KillCommand = False End If End If Catch ex As Exception End Try End Sub End Class End Namespace
On my command line I can see that the e.veto is triggered.
------------------
VETO MY COMMAND (True)
Updating fields...
28 field(s) found
28 field(s) updated
-----------------
Even if the e.veto has been sent to AutoCAD the ETRANSMIT command still continues
Without testing it... are you sure, that the document Lock change you cancel is indeed the one, which is caused by the eTransmit command?
Maybe you should check the running command in your documentlockchange handler
If (e.GlobalCommandName = "ETRANSMIT") Then
Can't find what you're looking for? Ask the community or share your knowledge.