How to assign multiple command from commandMethod

How to assign multiple command from commandMethod

kite15
Advocate Advocate
959 Views
2 Replies
Message 1 of 3

How to assign multiple command from commandMethod

kite15
Advocate
Advocate

Hi, Can any one help me how to assign multiple command from commandMethod...

 

******************************************************************************

[CommandMethod("CA", "CT", "CD", "CB", CommandFlags.Modal)]

static public void CommonCommandOfC()

{

  xxxxxx

}

**********************************************************

 

Thanks in advance

0 Likes
960 Views
2 Replies
Replies (2)
Message 2 of 3

Keith.Brown
Advisor
Advisor

 

 

@kite15 wrote:

Hi, Can any one help me how to assign multiple command from commandMethod...

 

******************************************************************************

[CommandMethod("CA", "CT", "CD", "CB", CommandFlags.Modal)]

static public void CommonCommandOfC()

{

  xxxxxx

}

**********************************************************

 

Thanks in advance


You cannot do that in the manner that you are showing.

 

If you need to define multiple commands to do something in code then you need to define each command individually and then have the code call a single method which performs the logic of the command.



[CommandMethod("CA", CommandFlags.Modal)]
static public void CommandCa()
{
     CommandCommon()
}

[CommandMethod("CT", CommandFlags.Modal)]
static public void CommandCT()
{
     CommandCommon()
}

[CommandMethod("CD", CommandFlags.Modal)]
static public void CommandCD()
{
     CommandCommon()
}

[CommandMethod("CB", CommandFlags.Modal)]
static public void CommandCB()
{
     CommandCommon()
}

static private void CommandCommon()
{
     //  Place command logic here.
}

A more Autocad way of doing it would to be to create a single command and then define command aliases to call the command in a different manner without any coding at all.

 

You can read about command aliases here.

Message 3 of 3

kite15
Advocate
Advocate

ThankYou...Will follow this

0 Likes