Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to capture radial marking menu command?

11 REPLIES 11
SOLVED
Reply
Message 1 of 12
rogmitch
1400 Views, 11 Replies

How to capture radial marking menu command?

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

 

11 REPLIES 11
Message 2 of 12
philippe.leefsma
in reply to: rogmitch

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

Message 3 of 12
rogmitch
in reply to: philippe.leefsma

Hi Philippe,

 

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

 

Roger

Message 4 of 12
rogmitch
in reply to: philippe.leefsma

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

 

 

Message 5 of 12
philippe.leefsma
in reply to: rogmitch

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

Message 6 of 12
rogmitch
in reply to: philippe.leefsma

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 

Message 7 of 12
rogmitch
in reply to: rogmitch

Philippe,

 

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

 

Roger

Message 8 of 12
rogmitch
in reply to: philippe.leefsma

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

Message 9 of 12
rogmitch
in reply to: rogmitch

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

 

 

Message 10 of 12
RedTopTraining
in reply to: rogmitch

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.

Message 11 of 12

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?
Message 12 of 12

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report