Add RibbonPanel

Add RibbonPanel

Anonymous
Not applicable
444 Views
4 Replies
Message 1 of 5

Add RibbonPanel

Anonymous
Not applicable
           
I think I need to update some legacy code in one of my add-ins. This used to create a ribbon panel and/or add it to the drawing toolbar if was already created. When I unload the add-in the panel is removed but a releoad does not work and the panel is never shown. Any ideas as to what the new code should look like? I don't think the Try's are necessary anymore either.
 
 
Try
 
oPanel = oUIManager.Ribbons("Drawing").RibbonTabs("id_TabTools").RibbonPanels("id_Cadtoolboxtab")
 
Catch ex As Exception
oPanel = oUIManager.Ribbons("Drawing").RibbonTabs("id_TabTools").RibbonPanels.Add _
("CAD Toolbox", "id_Cadtoolboxtab", "{1e7ab662-0fa3-4f9b-9dd4-89c12ef9aa06}")
End Try
0 Likes
445 Views
4 Replies
Replies (4)
Message 2 of 5

Owner2229
Advisor
Advisor

HI, you can try this:

 

 

Dim m_ButtonDefinition As ButtonDefinition
m_ButtonDefinition = InventorApplication.CommandManager.ControlDefinitions.AddButtonDefinition( _
   "Display Name", _
"Internal Name", _
CommandTypesEnum.kNonShapeEditCmdType, _
"{1e7ab662-0fa3-4f9b-9dd4-89c12ef9aa06}", _
"Description", _
   "Tool Tip", _
"PictureSmallIcon.bmp", _
"PictureLargeIcon.bmp", _
ButtonDisplayEnum.kDisplayTextInLearningMode)

Dim UIManager As Inventor.UserInterfaceManager UIManager = InventorApplication.UserInterfaceManager Dim oTab As Inventor.RibbonTab oTab = UIManager.Ribbons.Item("Drawing").RibbonTabs.Item("id_TabTools")
Dim panel As Inventor.RibbonPanel Try panel = oTab.RibbonPanels.Add("CAD Toolbox", _ "id_Cadtoolboxtab", "{1e7ab662-0fa3-4f9b-9dd4-89c12ef9aa06}") Catch panel = oTab.RibbonPanels.Item("id_Cadtoolboxtab") End Try
panel.CommandControls.AddButton(m_ButtonDefinition, True) 'True for big button

 

Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
0 Likes
Message 3 of 5

Anonymous
Not applicable

It still doesn't reappear when I reload it from the add-ins menu. It only reloads at restart of Inventor.

0 Likes
Message 4 of 5

Anonymous
Not applicable

This line always pops an error if the add-in is reloaded manually:

 

panel.CommandControls.AddButton(m_ButtonDefinition​, True)

 

0 Likes
Message 5 of 5

adam.nagy
Autodesk Support
Autodesk Support

Hi Thomas,

 

Are you removing the controls when your add-in is unloading?

http://adndevblog.typepad.com/manufacturing/2015/12/cannot-load-or-reload-add-in.html

 

Cheers



Adam Nagy
Autodesk Platform Services
0 Likes