Page 1 of 1

method DocumentLockModeChangedEventArgs.Veto() is missing

Posted: Tue Mar 17, 2020 7:21 pm
by geza.szabo
Hi,

I would need to stop a particular command execution.

In AutoCAD by handling the event Application.DocumentManager.DocumentLockModeChanged and calling the event parameter DocumentLockModeChangedEventArgs.Veto() the command can be cancelled. (See for example https://www.keanw.com/2006/10/blocking_autoca.html)
However in the IntelliCAD implementation the Veto method is missing.
Would you able to recommend how to achieve the same in IntelliCAD?

Here is a code example. Args.Veto() can not be resolved

Code: Select all

private static void DocumentLockModeChanged(object sender, DocumentLockModeChangedEventArgs args)
		{
			_runCustomCommand = false;
			Editor editor = Application.DocumentManager.MdiActiveDocument.Editor;

			if (args.GlobalCommandName.Length > 0)
			{
				if (_selectedEntId != ObjectId.Null &&
					!string.IsNullOrEmpty(_customCmd) &&
					args.GlobalCommandName.ToUpper() != _customCmd.ToUpper())
				{
					editor.WriteMessage(
						"\nCommand {0} is vetoed!", args.GlobalCommandName);
					
					args.Veto(); <= can not resolve Veto
					_runCustomCommand = true;
				}
			}
		}

Kind regards
Geza

Re: method DocumentLockModeChangedEventArgs.Veto() is missing

Posted: Wed Mar 18, 2020 12:22 am
by QuanNguyen
Hi,

Yes, it seems that the method DocumentLockModeChangedEventArgs.Veto() missing.
I saw the DocumentBeginCloseEventArgs having one.

Please try using the Document.CommandWillStart method to catch which command is active then do something as you want.

Document dwg = CadApp.DocumentManager.MdiActiveDocument;
dwg.CommandWillStart += new CommandEventHandler(Document_CommandWillStart);

Code: Select all

        private static void Document_CommandWillStart(object sender, CommandEventArgs e)
        {
            if (e.GlobalCommandName == "_LINE")
            {
                CadApp.ShowAlertDialog("Command LINE is starting.");

                // do something here
            }
        }
            

Re: method DocumentLockModeChangedEventArgs.Veto() is missing

Posted: Wed Mar 18, 2020 1:07 am
by geza.szabo
Thanks. I would need to stop the command happening. What would be a safest way to do that in CommandStart?

Re: method DocumentLockModeChangedEventArgs.Veto() is missing

Posted: Thu Mar 19, 2020 3:19 am
by QuanNguyen
I try to send the escape key to exit when the command willStart but the event not fired.
Not sure what's wrong!

Code: Select all

dwg.SendStringToExecute("\x1B\x1B", true, false, true);

Re: method DocumentLockModeChangedEventArgs.Veto() is missing

Posted: Sun May 10, 2020 3:16 pm
by geza.szabo
Hi, ESC is not working very well. Ctrl-C is more reliable but does not work all the time. Very annoying for our customers. Would be nice to implement Veto.
Kind regards
Geza