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.
We can also create various Inventor ribbon buttons, controls, panels, and tabs. In this post, let’s see how to move a Ribbon Panel.
public void RibbonMiscellanous()
{
UserInterfaceManager uiMan = AddinGlobal.InventorApp.UserInterfaceManager;
if (uiMan.InterfaceStyle == InterfaceStyleEnum.kRibbonInterface)
{
RibbonTab tab = GetSetRibbonTab("Presentation", "INAW2", null);
RibbonPanel panel = GetSetRibbonPanel(tab, "INAW Panel16", null);
Icon icon = new Icon(this.GetType(), "addin.ico"); // ICO embedded
InventorButton button1 = new InventorButton(
"Reposition", "INAW.InventorAddin.Presentation_INAW_INAWPanel16_BigButton1", "Button Reposition description", "Button Reposition tooltip",
icon, icon,
CommandTypesEnum.kShapeEditCmdType, ButtonDisplayEnum.kDisplayTextInLearningMode);
button1.Execute = () => panel.Reposition("idPanel_Presentation_INAW2_INAW_Panel12", true);
InventorButton button2 = new InventorButton(
"Move", "INAW.InventorAddin.Presentation_INAW_INAWPanel16_BigButton2", "Button Move description", "Button Move tooltip",
icon, icon,
CommandTypesEnum.kEditMaskCmdType, ButtonDisplayEnum.kAlwaysDisplayText);
button2.Execute = () => panel.Move(200, 200);
InventorButton button3 = new InventorButton(
"Hide", "INAW.InventorAddin.Presentation_INAW_INAWPanel16_BigButton3", "Button Hide description", "Button Hide tooltip",
icon, icon,
CommandTypesEnum.kEditMaskCmdType, ButtonDisplayEnum.kAlwaysDisplayText);
button3.Execute = () => { panel.Visible = false; };
CommandControls cmdCtrls = panel.CommandControls;
cmdCtrls.AddButton(button1.ButtonDef, true, true, "", false);
cmdCtrls.AddButton(button2.ButtonDef, true, true, "", false);
cmdCtrls.AddButton(button3.ButtonDef, true, true, "", false);
}
}
Here is what the ribbon tab looks like before the Move button in the INAW Panel16 is clicked:
Here is what the ribbon tab looks like after the Move button in the INAW Panel16 is clicked:
The leading edge Inventor .NET Addin Wizard (InventorNetAddinWizard) can be found and downloaded from the A Wizard for Inventor .NET Addin page.
Posted by: |