Adding a custom radial marking menu

Adding a custom radial marking menu

basnederveen
Advocate Advocate
1,217 Views
1 Reply
Message 1 of 2

Adding a custom radial marking menu

basnederveen
Advocate
Advocate

Hi everyone,

 

I've been struggling with customizing a marking menu. I do not want to add some button to an existing marking menu but create a custom marking menu when I right click a certain object.

 

The object is now a sketchedsymbol, when I get the linearMarkingMenu my code starts and i want to add a radial menu with some custom commands. The problem is that the radial menu is not showing at all for this selection.

 

I use the following code for testing:

' Declare the event objects
Private WithEvents oUserInputEvents As UserInputEvents

' Create a flag for when selecting is started or finished
Private bSelecting As Boolean

' Initialize the class to start watching events
Sub Init()

    ' Create an InteractionEvents object.
    Set oUserInputEvents = ThisApplication.CommandManager.UserInputEvents
               
End Sub
Private Sub oUserInputEvents_OnPreSelect(PreSelectEntity As Object, DoHighlight As Boolean, MorePreSelectEntities As ObjectCollection, ByVal SelectionDevice As SelectionDeviceEnum, ByVal ModelPosition As Point, ByVal ViewPosition As Point2d, ByVal View As View)

    ' Check if the preselected entity is a sketchsymbol
    If TypeOf PreSelectEntity Is SketchedSymbol Then
             bSelecting = True
        End If
    End If

End Sub
Private Sub oUserInputEvents_OnLinearMarkingMenu(ByVal SelectedEntities As ObjectsEnumerator, ByVal SelectionDevice As SelectionDeviceEnum, ByVal LinearMenu As CommandControls, ByVal AdditionalInfo As NameValueMap)
    
    If bSelecting Then
        Call Create_MarkingMenu(SelectedEntities.Item(1))
    End If
    
End Sub
Private Sub Create_MarkingMenu(SelectedEntity As Object)

    Dim rrm As RadialMarkingMenu
    Set rrm = ThisApplication.UserInterfaceManager.ActiveEnvironment.GetRadialMarkingMenu(ObjectTypeEnum.kSketchedSymbolObject)

    ' Define some test buttons
    Dim oDef1 As ButtonDefinition
    Set oDef1 = ThisApplication.CommandManager.ControlDefinitions.Item("AppZoomAllCmd")

    Dim oDef2 As ButtonDefinition
    Set oDef2 = ThisApplication.CommandManager.ControlDefinitions.Item("AppIsometricViewCmd")
    
    Set rrm.NorthControl = oDef1
    Set rrm.SouthControl = oDef2

End Sub

I've tried 

 

ThisApplication.UserInterfaceManager.ActiveEnvironment.GetRadialMarkingMenu(), with this I do get a menu, so apparently it is present it is just not showing. How do I show this menu?

 

and 

 

ThisApplication.UserInterfaceManager.ActiveEnvironment.RadialMarkingMenus.Add(), with this I've apparently added a new 'Sub-environment' to the customize marking menu, also great. How do I get this menu to show up for example after clicking a button or a different event? Or how do I add this to a linear markingmenu which does not have a radial menu?

 

 

0 Likes
Accepted solutions (1)
1,218 Views
1 Reply
Reply (1)
Message 2 of 2

Curtis_Waguespack
Consultant
Consultant
Accepted solution

 

I know this is an old thread, but I was just working on this as well.

 

Here is an example Visual Studio project, working with Inventor 2023, that provides a working example of this.

 

This example creates 2 custom radial menus. One general one that displays on the radial menu when it displays, and another that only shows when a parts lists is right clicked on ( parts lists do not have any radial menu out of the box) 

 

When clicking on a parts list you see 2 custom sub menus

 

Curtis_Waguespack_0-1680643815129.png

 

The contents of the General Hello Tools submenu has the 3 buttons

 

Curtis_Waguespack_2-1680644025785.png

 

The contents of the Parts List Hello Tools submenu has the 3 buttons

Curtis_Waguespack_1-1680643960290.png

 

When clicking in empty space on a drawing sheet you see this, you get only the General Hello Tools in the custom submenu as shown:

Curtis_Waguespack_3-1680644121942.png

 

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

 

 

 

 

 

 

        Private Sub OnSelectEvent() Handles UserInputEvents.OnSelect

            Dim oApp As Inventor.Application = g_inventorApplication
            Dim oDoc As Document = oApp.ActiveDocument
            Dim oSelectSet As SelectSet = oDoc.SelectSet

            Dim RadialMenu As RadialMarkingMenu
            Dim subMenu As RadialMarkingMenu


            Dim obj As Object = oSelectSet.Item(1)

            'if a parts list is selected
            If obj.type = ObjectTypeEnum.kPartsListObject Then

                RadialMenu = g_inventorApplication.UserInterfaceManager.ActiveEnvironment.GetRadialMarkingMenu(obj.type)

                subMenu = RadialMenu.CreateRadialSubMenu("Parts List Hello Tools")

                subMenu.EastControl = Hello_World_Button4
                subMenu.SoutheastControl = Hello_World_Button5
                subMenu.SouthControl = Hello_World_Button6

                RadialMenu.EastControl = subMenu 'right of radial menu
            End If

        End Sub

 

 

 

 

 

 

EESignature

0 Likes