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: 

How to intercept a click event on a custom ribbon tab?

2 REPLIES 2
Reply
Message 1 of 3
LiamSmith2
1689 Views, 2 Replies

How to intercept a click event on a custom ribbon tab?

I have a have a custom ribbon tab on the Assembly and ZeroDoc ribbons, those have pannels and buttons.

The custom buttons have OnExecute event that can have custom actions addded.

 

But how can we intercept the event when user is clicking on the custom tab to show custom pannels?

Is there a OnExecute or a similar event for the RiboonTab?

2 REPLIES 2
Message 2 of 3

Hi There,

 

There is no specific event directly exposed in the Inventor API when a specific tab is activated, however you can use the underlying API to get access to that notification.

 

You would need to reference the AdWindows.dll in order to use that code.

 

Here is a C# sample that will display a notification when the "Tools" tab of the ZerocDoc Ribbon gets activated:

 

public override void Activate(
    ApplicationAddInSite addInSiteObject,
    bool firstTime)
{
    base.Activate(addInSiteObject, firstTime);

    Autodesk.Windows.ComponentManager.ItemInitialized += 
        new EventHandler<RibbonItemEventArgs>(
            ComponentManager_ItemInitialized);
}

void ComponentManager_ItemInitialized(object sender, RibbonItemEventArgs e)
{
    //now one Ribbon item is initialized, but the Ribbon control
    //may not be available yet, so check before
    if (Autodesk.Windows.ComponentManager.Ribbon != null)
    {
        foreach (Autodesk.Windows.RibbonTab Tab in Autodesk.Windows.ComponentManager.Ribbon.Tabs)
        {
            if (Tab.Id == "id_TabTools")
            {
                Tab.Activated += new EventHandler(Tab_Activated);
            }
        }

        //and remove the event handler
        Autodesk.Windows.ComponentManager.ItemInitialized -=
            new EventHandler<RibbonItemEventArgs>(ComponentManager_ItemInitialized);
    }
}

void Tab_Activated(object sender, EventArgs e)
{
    System.Windows.Forms.MessageBox.Show(
        "Tab " + ComponentManager.Ribbon.ActiveTab.Id + " Activated!");
}

 Regards,

Philippe.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Message 3 of 3

Hi,Phil,

I have my add in in VB.NET. Is it possible your code has a VB.NET version? Or how to integrate this C# script into vb.net addin?

Thanks
Limin
Inventor pro 2023 64 bit update 2.1; Windows 10 pro 64 bit version 21H2; Office 2013 32 bit

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

Post to forums  

Autodesk Design & Make Report