How to add button on the top toolbar of Inventor?

How to add button on the top toolbar of Inventor?

yuzeaa
Advocate Advocate
984 Views
4 Replies
Message 1 of 5

How to add button on the top toolbar of Inventor?

yuzeaa
Advocate
Advocate

I have created an addin,but I want my button show on the quick access toolbar. I have seen other addin do this.Anyone know how to do it?

3333.jpg

Private Sub AddToUserInterface()
Dim assemblyRibbon As Ribbon = ThisApplication.UserInterfaceManager.Ribbons.Item("Assembly")
Dim assemTab As RibbonTab = assemblyRibbon.RibbonTabs.Item("id_TabAssemble")
Dim customPanel As RibbonPanel = assemTab.RibbonPanels.Add("mypanel", "mypanel_1", AddInClientID)
customPanel.CommandControls.AddButton(mybutton)
End Sub

 

0 Likes
Accepted solutions (2)
985 Views
4 Replies
Replies (4)
Message 2 of 5

Ralf_Krieg
Advisor
Advisor
Accepted solution

Hello

 

Maybe like this?

assemblyRibbon.QuickAccessControls.AddButton(mybutton)

 


R. Krieg
RKW Solutions
www.rkw-solutions.com
Message 3 of 5

yuzeaa
Advocate
Advocate

Thanks,it works!

More questions:

1.How to change the order of the button?

2.Can I add my button to the mouse right click panel?

88888.jpg

0 Likes
Message 4 of 5

Ralf_Krieg
Advisor
Advisor
Accepted solution

Hello

 

You need to get the CommandControl before or after which you want to add your button. The assemblyRibbon.QuickAccessControls.AddButton method has options for TargetControl and InsertBeforeTargetControl.

Dim oTargetControl As CommandControl 
oTargetControl = ThisApplication.CommandManager.CommandControls.Item("ID_QAT_Assembly_Select")
assemblyRibbon.QuickAccessControls.AddButton(mybutton, False, False, oTargetControl, False)

 

You can use the OnContextMenu Event. Add a handler for it and check the values of the AdditionalInfo and CommandBar evetn objects to check if the conetxt is the one you want to add your button. If so, add your button to the CommandBar Object that comes with the event. Afaik like CommandBar.Controls.AddButton(yourButtonDefinition, i) where "i" is a Long defining the position in CommandBar. If i is not set, your button will be inserted at the end.


R. Krieg
RKW Solutions
www.rkw-solutions.com
Message 5 of 5

yuzeaa
Advocate
Advocate

Thanks,it helps.

It has somthing wrong with getting the CommandControl object,so I change the code like this and it works:

 

assemblyRibbon.QuickAccessControls.AddButton(mybutton, False, False, "ID_QAT_Assembly_Select", False)
0 Likes