I've got a plugin that I made using VB.NET, and it's got a custom ribbon tab. Everything works fine when debugging, and also when I load the plugin using netload. When I try to load the plugin automatically though, it doesn't seem to be adding the ribbon tab (my commands work fine though, so the plugin is definitely loading). I'm trying to load it via the registry, for what it's worth...for my environment, that's the best way.
I'm guessing it's not able to run the init function because there's no ribbon object yet. I've looked at some forum posts and it seems the solution is to check Autodesk.Windows.ComponentManager.ItemInitialized and use a handler....the problem is that all the exmaples are in C#. I translated them to the best of my abaility, and things are compiling just fine, but I'm still not seeing the ribbon tab.
Here's some of my code:
Public Sub Initialize() Implements IExtensionApplication.Initialize If Autodesk.Windows.ComponentManager.Ribbon Is Nothing Then AddHandler Autodesk.Windows.ComponentManager.ItemInitialized, AddressOf ComponentManager_ItemInitialized Else MyRibbon() End If End Sub Public Sub ComponentManager_ItemInitialized(sender As Object, e As RibbonItemEventArgs) If Autodesk.Windows.ComponentManager.Ribbon Is Nothing Then 'create Ribbon MyRibbon() 'and remove the event handler RemoveHandler Autodesk.Windows.ComponentManager.ItemInitialized, AddressOf ComponentManager_ItemInitialized End If End Sub
Solved! Go to Solution.
Solved by andrew_demerchant. Go to Solution.
Perhaps I am way off course here but I added a ribbon as well in my application. In order for my ribbon to always be available, I had to create a partial CUI menu. Like so:
My menu is "LayoutCreator" and I added a couple commands to it. Is this what you're looking for?
Possibly what Alex was referring to was creating a partial CUI and adding it to the Autoloader. I switched over to doing it that way as it makes it easier to create the finished product. I just create my commands and then using a partial cui add the commands to a ribbon.
This fix worked like a champ for me. If anyone is interested in the C# equivalent, see below.
public class Initialization : IExtensionApplication
{
void IExtensionApplication.Initialize()
{
if (Autodesk.Windows.ComponentManager.Ribbon == null)
Autodesk.Windows.ComponentManager.ItemInitialized += ComponentManager_ItemInitialized;
else
LoadRibbon();
}
private void ComponentManager_ItemInitialized(object sender, RibbonItemEventArgs e)
{
if (Autodesk.Windows.ComponentManager.Ribbon != null) {
//Create Ribbon
LoadRibbon();
Autodesk.Windows.ComponentManager.ItemInitialized -= ComponentManager_ItemInitialized;
}
}
void IExtensionApplication.Terminate()
{
}
}