.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Veto ETRANSMIT command doesn't work

2 REPLIES 2
Reply
Message 1 of 3
RPeter
451 Views, 2 Replies

Veto ETRANSMIT command doesn't work

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

 

2 REPLIES 2
Message 2 of 3
Matti72
in reply to: RPeter

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

 

Message 3 of 3
RPeter
in reply to: RPeter

Original that was in my code.

So I know for sure the correct command is canceled.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost