How to capture radial marking menu command?

How to capture radial marking menu command?

rogmitch
Advocate Advocate
1,899 Views
11 Replies
Message 1 of 12

How to capture radial marking menu command?

rogmitch
Advocate
Advocate

I am trying to capture a command invoked by a radial menu control in VB.Net e.g.

 

RadialMenu.WestControl = _Application.CommandManager.ControlDefinitions("AppContextual_CancelCmd")

 

I tried UserInputEvents.OnActivateCommand and this captures other events OK  but does not fire if any of the radial menu controls are clicked.

 

Does anyone know a way around this problem?

 

Any help much appreciated.

 

Roger Mitchell

IV 2014 Prof SP1 VS 2013

 

0 Likes
Accepted solutions (1)
1,900 Views
11 Replies
Replies (11)
Message 2 of 12

philippe.leefsma
Alumni
Alumni
Accepted solution

Hi Roger,

 

You can use a similar approach than the one exposed in that blog post:

 

http://adndevblog.typepad.com/manufacturing/2014/02/replacing-a-native-inventor-button-by-a-custom-o...

 

Create your own control definition, replace the radial menu button by your own and invoke the native Execute when the button gets clicked.

 

Philippe.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 3 of 12

rogmitch
Advocate
Advocate

Hi Philippe,

 

Thank you very much for the help- it is much appreciated.  I will implement the custom button as you suggest.

 

Roger

0 Likes
Message 4 of 12

rogmitch
Advocate
Advocate

Hi Phillipe,

 

I introduced your 'AdnCustomReplacementCmd' class into my addin and it works great.

 

As I want to capture, for example, the Cancel command on a radial menu I removed the StandardIcon and LargeIcon parameters from the button definition otherwise I get an exception.  So far so good.

 

My problem is that the "AppContextual_CancelCmd"  is ignored in the ReplaceNativeControls().  From what I can tell the UserInterfaceManager.AllReferencedControls is for only for the ribbon interface. Unfortunately, I have been unable to find another way to reference the radial control and subsitute the button.

 

Any further help would be much appreciated.

 

Regards,

 

Roger Mitchell

 

 

0 Likes
Message 5 of 12

philippe.leefsma
Alumni
Alumni

The radial and linear menus are populated at runtime, so it's not possible to find references for all buttons during initialization.

 

I modified the blog sample so it works for radial menu now, although it doesn't handle the case where you would like to replace a button in a radial sub-menu. I'm not sure why the icons do not work, but you can definitely use your own, as illustrated in the following context menu sample:

 

http://adndevblog.typepad.com/manufacturing/2012/05/customizing-radialmarkingmenu-and-linearmarkingm...

 

Regards,

Philippe.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 6 of 12

rogmitch
Advocate
Advocate

Hi Phillipe,

 

Thank you for taking the time to update the class.  It is always good to learn new things and as an addin newbie I find the blogs paticularly helpful.

 

I will try and implement the revised code over the weekend.

 

Regards,

 

Roger 

0 Likes
Message 7 of 12

rogmitch
Advocate
Advocate

Philippe,

 

Oops - sorry about the spellling of your name.  Somehow I managed to garble it mid-topic.

 

Roger

0 Likes
Message 8 of 12

rogmitch
Advocate
Advocate

Hi Philippe,

 

I got the radial menu capture to work.  For your information I had to modify your code slightly as I found the 'InternalName' for the radial buttons is of the form 'AppNGX_command rather than 'AppContextual_command'.  By altering

 

If RadialMenu.EastControl.InternalName = _nativeButtonDef.InternalName Then

 

to 

 

If Mid(RadialMenu.EastControl.InternalName, InStr(RadialMenu.EastControl.InternalName, "_")) = Mid(_nativeButtonDef.InternalName, InStr(_nativeButtonDef.InternalName, "_")) Then

 

everything works fine.  

 

Once again thanks for your help

 

Roger

0 Likes
Message 9 of 12

rogmitch
Advocate
Advocate

Addendum:

 

To prevent an exception if a radial command is not an 'AppNGX_command' use, for example:

 

If TypeOf (RadialMenu.WestControl) Is ControlDefinition Then
If RadialMenu.WestControl.InternalName.ToString.Contains("_") Then
If Mid(RadialMenu.WestControl.InternalName, InStr(RadialMenu.WestControl.InternalName, "_")) = Mid(_nativeButtonDef.InternalName, InStr(_nativeButtonDef.InternalName, "_")) Then
RadialMenu.WestControl = _customButtonDefinition
End If
End If

 

 

0 Likes
Message 10 of 12

Anonymous
Not applicable

I found this very interesting, as the RadialMarkingMenu is populated on the fly, would it be possible to cature the name of any command that is run, for example when I right click in a new Part I get the following commands available: Fillet, Extrude, Revolve, Hole, New Sketch, Work Plane, Undo & Measure. If when one fo these was clicked I wanted a System.Windows.Forms.MessageBox to display this command name text string, would it be possible.

 

I can use the following event to capture the loading of the RadialMarkingMenu:

 

UserInputEvents inpEvents = inventorApplication.CommandManager.UserInputEvents;

inpEvents.OnRadialMarkingMenu += new Inventor.UserInputEventsSink_OnRadialMarkingMenuEventHandler(UIEvents_OnRadialMarkingMenu);

 

but I cant seem to find an event handler to handle the actual clicking on the Marking Menu once it is on display in the interface.

 

Any direction would be much appreciated.

0 Likes
Message 11 of 12

Anonymous
Not applicable
Sorry,
I read it back and I see that recreating the commands with an event handler in them is the solution, are there any dangers in this?
0 Likes
Message 12 of 12

philippe.leefsma
Alumni
Alumni

Hi

 

Your question is exactly what we've been answering in that forum thread. What do you mean by danger...? No it's a safe workaround and I don't see any easier way to achieve it. Nobody will get hurt, I'm pretty sure about that 🙂

 

Hope that helps,

Philippe.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

0 Likes