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: 

Replacing Controls (buttons) in sub-menus

2 REPLIES 2
Reply
Message 1 of 3
wood.isbell
363 Views, 2 Replies

Replacing Controls (buttons) in sub-menus

The goal here is to replace all of the Open Drawing commands (CMxOpenDrawingCmd) from context menus (LinearMenu) or add an alternate to the list adjacent to the original so that custom functions can be performed. Where it gets confusing is when the command shows up on a sub-menu such as in the case of a component in an assembly where it shows up under the "Component" menu. Below is what I would expect to work.

 

private void UserInputEvents_OnLinearMarkingMenu_Handler(ObjectsEnumerator SelectedEntities, 
    SelectionDeviceEnum SelectionDevice, CommandControls LinearMenu, NameValueMap AdditionalInfo)
{
    foreach (CommandControl ctrl in LinearMenu)
    {
        if (ctrl.InternalName == "CMxOpenDrawingCmd")
        {
            // Works.
        }
        CommandControls subCtrls = ctrl.ChildControls;
        if (subCtrls != null)
        {
            foreach (CommandControl subCtrl in subCtrls)
            {
                if (subCtrl.InternalName == "CMxOpenDrawingCmd")
                {
                    MessageBox.Show(subCtrl.DisplayName); //Never shows.
                }
            }
        }
    }
}

The result of this and other methods is that every time you find a CommandControl which has children, the children are always taken from the first sub-menu rather than the one you have iterated to. In my case, that would be the Vault sub-menu items which do not contain the command I am looking for. Since these sub-menus do not have an InternalName, what is the way to properly access their children rather than always being pushed to the top sub-menu?

2 REPLIES 2
Message 2 of 3
wayne.brill
in reply to: wood.isbell

Hi,

 

I am able to recreate this behavior and logged this ticket with Inventor Engineering:

"LinearMenu Sub Menu ChildControls incorrect in OnLinearMarkingMenu event"

 

I am not finding a work around to get the correct controls on the other Sub Menus.

 

Thanks,

Wayne



Wayne Brill
Developer Technical Services
Autodesk Developer Network

Message 3 of 3
wood.isbell
in reply to: wayne.brill

Thank you for the confirmation, Wayne. That was where I wound up after trying a large number of off-the-wall ideas. Short of removing the menu items down to the sub-menu you want and re-adding them later, I'm not sure there is a method. Even that way may cause issues if you cannot properly recreate the sub-menus you remove.

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

Post to forums  

Autodesk Design & Make Report