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
Solved! Go to Solution.
Solved by philippe.leefsma. Go to Solution.
Hi Roger,
You can use a similar approach than the one exposed in that blog post:
Create your own control definition, replace the radial menu button by your own and invoke the native Execute when the button gets clicked.
Philippe.
Hi Philippe,
Thank you very much for the help- it is much appreciated. I will implement the custom button as you suggest.
Roger
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
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:
Regards,
Philippe.
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
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
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
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.
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.