Reply
Solved! Go to solution

Command 'activation'

I've created a 2D Drafting Addin with ribbon in C# from Jason's templates.  I currently have a button that when clicked, looks at the select set and for each item in it, if it is a dimension, it applies a custom format to that dimension.

 

Although this works fine, I would like to be able to 'activate' the command by clicking the button and have it highlighted or something, then click dimensions in the view to format them. Then deactivate the command by Esc or right click. I.e. I'd like it to work more like the built in SE commands.

 

I don't necessarily want exact code, but what's the workflow to achieve this? 

3 REPLIES
Solution
Solution
Accepted by topic author Alex_H
‎09-29-2015 03:26 AM

Re: Command 'activation'

[ Edited ]

Hi Alex_H,

 

for your purpose exist the Command object and its Mouse property. The workflow would be as follows:

 

On click of your button you create an instance of the Command object and assign its Mouse property to a corresponding Mouse object. Now you configure your Command and Mouse objects. I.e. assign an event handler method for the mouse click event. In the mouse click event you will be able to locate the clicked object and in case of a dimension object perform your formatting. With the Start() method of your command instance you start the command and it behaves like a built in command.

Keyboard events (like detecting the press of the ESC key) can be handled by your program as usual. In the corresponding event handler for a key press of the ESC key you can terminate your started command instance by setting its property Done to true.

 

Jason has provided good examples of how to use the Command and Mouse objects in his examples downloadable on github.

 

Kind regards,
Wolfgang Kunert - www.wksyspro.de

Re: Command 'activation'

You bring up a good point though. I should add how to do this in the DemoAddin on GitHub. I'll do that and get back with you.

Jason Newell
Applications Architect
www.jasonnewell.net

Re: Command 'activation'

Thanks Wku, that's a good explanation. Also, Jason, a working example would be great.