RibbonPanel Error when exiting/entering plugin in C++

RibbonPanel Error when exiting/entering plugin in C++

Geoffrey.Bixby
Participant Participant
514 Views
2 Replies
Message 1 of 3

RibbonPanel Error when exiting/entering plugin in C++

Geoffrey.Bixby
Participant
Participant

In the demo project CustomUI in the source code CustomUIAddinServer.cpp, there is a new Tab added to the Part Ribbon.  


CComPtr<RibbonTab> pPartCustUIRibbonTab;
hr = pRibbonTabs->Add(CComBSTR(_T("CustomUI")),
CComBSTR(_T("Autodesk:CustomUI:CustomUIRibbonTab")),
CComBSTR(_T("{17ADEE74-528C-4682-84F8-9A64638D2E38}")), // Client id,
CComBSTR(_T("")),
VARIANT_FALSE,
VARIANT_FALSE,
&pPartCustUIRibbonTab);
if (FAILED(hr)) return hr;

 

I changed it so that instead of creating a new tab, it will get the tools tab.

Example:

CComPtr<RibbonTab> pPartCustUIRibbonTab;
hr = pRibbonTabs->get_Item(CComVariant(_T("id_TabTools")), &pPartCustUIRibbonTab);

 

There is an error in pRibbonPanels->Add(), it returns fail.   To reproduce the error, go to the plugin manager and load the plugin, unload the plugin,  load it a 2nd time.  You will notice that the plugin fails to load, its because there was an error when adding a panel to the tab.

 

I think this is happening because the clean up must be different does anyone know what is wrong?

I have attached the CustomUI project with the change.

0 Likes
Accepted solutions (1)
515 Views
2 Replies
Replies (2)
Message 2 of 3

chandra.shekar.g
Autodesk Support
Autodesk Support
Accepted solution

@Geoffrey.Bixby,

 

You should clear up the custom panel when unload the addin. i.e. delete the ribbon panel which he added to the Tools ribbon tab in the OnDeactivate event. Otherwise when he reload the addin, it will add the same ribbon panel twice and raise an error.

 

For more details, refer sample c++ addin available at SDK path(C:\Users\Public\Documents\Autodesk\Inventor 2019\SDK\DeveloperTools\Samples\VC++\AddIns\CustomCommand)

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 3 of 3

Geoffrey.Bixby
Participant
Participant

Thanks for the solution.  The odd part is that in the sample the UI is not deleted manually and there is no error when reloading the plugin.   Only the commands seem to be deleted.  

0 Likes