Get command name from autocad electrical

Get command name from autocad electrical

kebby70
Contributor Contributor
670 Views
4 Replies
Message 1 of 5

Get command name from autocad electrical

kebby70
Contributor
Contributor

I would like to add a function to check whether AEWIRENO which a command of autocad electrical has been executed.
Commands such as copy and move can be checked for execution, but AEWIRENO is not recognized in GLOBALNAME.
please tell me how.

 

My code is below

public void Initialize()
{

Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.DocumentLockModeChanged += new DocumentLockModeChangedEventHandler(vetoCommand);

}

 

private void vetoCommand(object sender, DocumentLockModeChangedEventArgs e)
{
if (e.GlobalCommandName == "COPY")
{
e.Veto();
MessageBox.Show("COPY");
}

if (e.GlobalCommandName == "MOVE")
{
e.Veto();
MessageBox.Show("MOVE");
}

if (e.GlobalCommandName == "AEWIRENO")
{
e.Veto();
MessageBox.Show("AEWIRENO");
}
}

0 Likes
671 Views
4 Replies
Replies (4)
Message 2 of 5

ditran7577
Advocate
Advocate

Maybe it defined in group name. Try groupName or add globalName.

 

image.png

0 Likes
Message 3 of 5

kebby70
Contributor
Contributor

.

0 Likes
Message 4 of 5

kebby70
Contributor
Contributor

I don't know how to use, could you explain in detail?

0 Likes
Message 5 of 5

Norman_Yuan
Mentor
Mentor

You can easily find out why the said command is not caught in the DocumentLockModeChanged event handler by simply place a break point in the event handler to examine the event argument, and run the said command. 

 

If the beak point is hit, you can then examine what exactly the GlobalCommand value is; if not hit, the said command is not a "real" command, it is probably a LISP routine defined as (defun c:xxxxx....), which would not raise DocumentLockModeChanged event when it begins (but its code could raise this event along with its execution, if the lisp routine has statement like (command "xxxxx"....)...).

Norman Yuan

Drive CAD With Code

EESignature

0 Likes