The Inventor API has provided the Ribbon API for some time. We can use the Inventor Ribbon API to access to those existing Ribbon UI elements such as Ribbon Environment, Ribbon Tab, Ribbon Panel, Ribbon Button, Various Ribbon Controls, and so on.
In these series, we are going to look at the Application Menu (File Browser Controls). In this post, let’s specifically add a Ribbon Popup to the Application Menu (File Browser Controls).
public void AddPopupToApplicationMenu()
{
UserInterfaceManager uiMan = AddinGlobal.InventorApp.UserInterfaceManager;
if (uiMan.InterfaceStyle == InterfaceStyleEnum.kRibbonInterface)
{
Icon icon = new Icon(this.GetType(), "addin.ico"); // ICO embedded
InventorButton button1 = new InventorButton(
"Button 1", "INAW.InventorAddin.Presentation_ApplicationMenu_Popup_Button1", "Button 1 description", "Button 1 tooltip",
icon, icon,
CommandTypesEnum.kShapeEditCmdType, ButtonDisplayEnum.kDisplayTextInLearningMode);
button1.Execute = () => MessageBox.Show("Hi, I'm Popup_Button1."); // lambda expression.
InventorButton button2 = new InventorButton(
"Button 2", "INAW.InventorAddin.Presentation_ApplicationMenu_Popup_Button2", "Button 2 description", "Button 2 tooltip",
icon, icon,
CommandTypesEnum.kEditMaskCmdType, ButtonDisplayEnum.kAlwaysDisplayText);
button2.Execute = () => MessageBox.Show("Hi, I'm Popup_Button2.");
ObjectCollection controls = AddinGlobal.InventorApp.TransientObjects.CreateObjectCollection();
controls.Add(button1.ButtonDef);
controls.Add(button2.ButtonDef);
AddinGlobal.InventorApp.UserInterfaceManager.FileBrowserControls.AddPopup(button2.ButtonDef, controls);
}
}
As can be seen, the key point is to get the Ribbon Application Menu (File Browser Controls) from the Inventor Application through the UserInterfaceManager.FileBrowserControls property. Then adding a Popup to the Ribbon Application Menu (File Browser Controls) is pretty much the same as doing so to a Ribbon Panel that we have demonstrated many times.
Here is what the Popup looks like in the Application Menu (File Browser Controls):
The leading edge Inventor .NET Addin Wizard (InventorNetAddinWizard) can be found and downloaded from the A Wizard for Inventor .NET Addin page.
Posted by: |