.NET

Reply
Valued Contributor
RPeter
Posts: 91
Registered: ‎01-09-2009
Message 1 of 3 (211 Views)

Veto ETRANSMIT command doesn't work

211 Views, 2 Replies
09-13-2013 02:04 AM

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

 

Contributor
Matti72
Posts: 25
Registered: ‎09-28-2004
Message 2 of 3 (206 Views)

Re: Veto ETRANSMIT command doesn't work

09-13-2013 02:32 AM 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

 

Valued Contributor
RPeter
Posts: 91
Registered: ‎01-09-2009
Message 3 of 3 (202 Views)

Re: Veto ETRANSMIT command doesn't work

09-13-2013 02:40 AM in reply to: RPeter

Original that was in my code.

So I know for sure the correct command is canceled.

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.