Submenu in linear marking menu

Submenu in linear marking menu

jan.pomplun
Contributor Contributor
1,395 Views
11 Replies
Message 1 of 12

Submenu in linear marking menu

jan.pomplun
Contributor
Contributor

Hi,

 

I want to extend the linear context menu by a sub menu as shown here ("Messen"):

 

subMenu.png

 

I know how to add usual buttons via:

 

public void UserInputEvents_OnLinearMarkingMenu_Handler(ObjectsEnumerator selectedEntities, SelectionDeviceEnum selectionDevice, CommandControls linearMenu, NameValueMap additionalInfo)

{

    linearMenu.AddButton(...);

}

 

but can not find any example/documentation, how to add a sub menu.

 

Thanks,

 

Jan

0 Likes
1,396 Views
11 Replies
Replies (11)
Message 2 of 12

bradeneuropeArthur
Mentor
Mentor

CommandControls.AddSplitButton..........

For Example:

Sub AddPanelToToolsTab()
    ' Get the ribbon associated with the part document
    Dim oPartRibbon As Ribbon
    Set oPartRibbon = ThisApplication.UserInterfaceManager.Ribbons.Item("Part")

    ' Get the "Tools" tab
    Dim oTab As RibbonTab
    Set oTab = oPartRibbon.RibbonTabs.Item("id_TabTools")

    ' Create a panel named "Update", positioned after the "Measure" panel in the Tools tab.
    Dim oPanel As RibbonPanel
    Set oPanel = oTab.RibbonPanels.Add("Update", "ToolsTabUpdatePanel", "SampleClientId", "id_PanelP_ToolsMeasure")

    ' Get the update commands
    Dim oDef1 As ButtonDefinition
    Set oDef1 = ThisApplication.CommandManager.ControlDefinitions.Item("AppLocalUpdateCmd")

    Dim oDef2 As ButtonDefinition
    Set oDef2 = ThisApplication.CommandManager.ControlDefinitions.Item("AppUpdateMassPropertiesCmd")

    Dim oDefs As ObjectCollection
    Set oDefs = ThisApplication.TransientObjects.CreateObjectCollection

    oDefs.Add oDef1
    oDefs.Add oDef2

    ' Create a split button control
    Call oPanel.CommandControls.AddSplitButton(oDef1, oDefs, True)

    ' Get the rebuild command
    Dim oDef3 As ButtonDefinition
    Set oDef3 = ThisApplication.CommandManager.ControlDefinitions.Item("AppRebuildAllWrapperCmd")

    ' Create a button control
    Call oPanel.CommandControls.AddButton(oDef3, True)
End Sub

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 3 of 12

jan.pomplun
Contributor
Contributor

I am having issues with the examples I find.

Adding the Split Button to ribbons control works:

                    ButtonDefinition button = (ButtonDefinition)InventorUtil.InventorApplication.CommandManager.ControlDefinitions["AppLocalUpdateCmd"];
                    ObjectCollection subDefTest = InventorUtil.InventorApplication.TransientObjects.CreateObjectCollection();
                    subDefTest.Add(button);
                    blockManagementRibbonPanelCtrls.AddSplitButton(button, subDefTest);

the same code however fails on the linear menu:

        public void UserInputEvents_OnLinearMarkingMenu_Handler(ObjectsEnumerator selectedEntities, SelectionDeviceEnum selectionDevice, CommandControls linearMenu, NameValueMap additionalInfo)
        {
                            ButtonDefinition button =(ButtonDefinition) InventorUtil.InventorApplication.CommandManager.ControlDefinitions["AppLocalUpdateCmd"];
                            ObjectCollection subDefTest = InventorUtil.InventorApplication.TransientObjects.CreateObjectCollection();
                            subDefTest.Add(button);

                            linearMenu.AddSplitButton(button, subDefTest);
}

an exception is thrown:

System.Runtime.InteropServices.COMException: "Unbekannter Fehler (Ausnahme von HRESULT: 0x80004005 (E_FAIL))"

Do split buttons work in the context menu?

 

Thanks and best,

 

Jan

0 Likes
Message 4 of 12

dgreatice
Collaborator
Collaborator

hi,

 

try find some information from:

 

http://help.autodesk.com/view/INVNTOR/2018/ENU/?guid=GUID-20E1627B-F1B6-45A4-A1EB-A28750F761FB

 

I think marking menu not use ButtonDefinition, but use ControlDefinitions

 

Please use the ACCEPT AS SOLUTION or KUDOS button if my Idea helped you to solve the problem.

Autodesk Inventor Professional Certified 2014
0 Likes
Message 5 of 12

dgreatice
Collaborator
Collaborator

for Commandcontrols.AddSplitButton or AddSplitButtonMRU object must be ControlDefinition, not Buttondefinition.

 

 

Please use the ACCEPT AS SOLUTION or KUDOS button if my Idea helped you to solve the problem.

Autodesk Inventor Professional Certified 2014
0 Likes
Message 6 of 12

bradeneuropeArthur
Mentor
Mentor
 Private Sub oUserInputEvents_OnContextMenu(SelectionDevice As Inventor.SelectionDeviceEnum, AdditionalInfo As Inventor.NameValueMap, CommandBar As Inventor.CommandBar) Handles oUserInputEvents.OnContextMenu

For Each control As CommandBarControl In CommandBar.Controls

 Try
            ' Check if the context menu has the 'Home View' (formerly 'Isometric View') command
            Dim oCmdBarControl As CommandBarControl
            oCmdBarControl = CommandBar.Controls.Item("AppIsometricViewCmd")

            Dim ControlsCounter As Integer
            ControlsCounter = CommandBar.Controls.Count

            If Not oCmdBarControl Is Nothing Then

                ' add the buttonCommand to the end
                Call oCommandBar.Controls.AddsplitButton(!!!!!!!!!)

            End If
        Catch ex As Exception

        End Try

next

end sub

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 7 of 12

jan.pomplun
Contributor
Contributor

the link points to

 

RadialMarkingMenu Objects

 

help. This is not what I am trying to do.

The split button is intended to be added to the linear menu not the radial

 

mEventsObj.OnLinearMarkingMenu += UserInputEvents_OnLinearMarkingMenu_Handler;

0 Likes
Message 8 of 12

jan.pomplun
Contributor
Contributor

After some research it seems to be an old problem:

Buttons (other than ordinary) can not be added to the context menu:

 

https://forums.autodesk.com/t5/inventor-customization/how-to-add-a-amp-quot-popupbutton-amp-quot-in/...

 

as so often the problem has been reported ages ago, and is still not fixed 😞

 

Does autodesk have the intention to fix it?

0 Likes
Message 9 of 12

bradeneuropeArthur
Mentor
Mentor

of course it is possible:

RmbMenu.png

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 10 of 12

jan.pomplun
Contributor
Contributor

Hi,

 

the picture is cropped, I can not see where this is a SUB menu.

Can you post the code?

I know that inventor has submenus, as the picture of my original post shows, but I get an exception thrown when I add the split button to the context menu.

The same code works adding the split button to the ribbon, so I do not see what I am doing wrong.

 

Thakns and best,

 

Jan

0 Likes
Message 11 of 12

bradeneuropeArthur
Mentor
Mentor

ok.
i will try..........

the buttons are added to the RMB menu Context menu.

 

I will try to add a submenu.

 

Will come back to it ASAP....

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 12 of 12

c_hoppen
Advocate
Advocate

@bradeneuropeArthur  schrieb:

 

Will come back to it ASAP....


He never came back 😉

Is there a solution for this in the meantime?