.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Another plugin stops my plugin ribbon from displaying

0 REPLIES 0
Reply
Message 1 of 1
jhdempsey
52 Views, 0 Replies

Another plugin stops my plugin ribbon from displaying

I have a plugin which creates its own tab on the ribbon.
My code works, and the tab on the ribbon loads as expected.
 
The only exception is when AutoCAD is launched with the PDS Sign plugin
PDS Sign works by clicking an icon on your desktop which launches AutoCAD with a specific "PDS Sign" profile
 
When AutoCAD launches with this profile, I can confirm that my plugin launches, and the code which creates the tab on the ribbon runs successfully. I know this because I get it to show a MessageBox immediately after the code which creates the tab (see screenshot below and code at end of this post). But, we cannot see the tab I created on the ribbon. It doesn't appear to be hidden or turned off, as I cant see it in the list of tabs available when I right click on the ribbon (see second screenshot)
jhdempsey_0-1697717014696.pngjhdempsey_1-1697717102436.png

 

 
Does anyone know what PDS Sign could be doing to stop my ribbon from showing?
 
Just in case, here is the code I use to create the ribbon tab in my plugin
 

 

public void Initialize()
{
    try
    {
        // Handle idle event for any setup functions, then remove it after
        try
        {
            MessageBox.Show("Initializing Jacobs Tools");
            Application.Idle -= LoadRibbonMenuOnIdle;
        }
        catch (System.Exception ex)
        {
            // No need to deal with error. Will only throw error if there was no event to remove;
        }

        Application.Idle += LoadRibbonMenuOnIdle;

// Further initialization tasks....
}
}

private void LoadRibbonMenuOnIdle(object sender, EventArgs e)
{
    MessageBox.Show("Running LoadRibbonMenuOnIdle method");

    var ribbonControl = Autodesk.Windows.ComponentManager.Ribbon;

    if (ribbonControl != null && ribbonControl.Tabs != null)
    {
        // Load custom ribbon / menu
        SetUpRibbon();

        // Ribbon now loaded. Add in an event to check when the user has changed the worksapce
        // If they have, we need to reload the ribbon again as it will
        // have got removed when the ribbon was rebuilt during the workspace change
        Application.SystemVariableChanged += (o, w) =>
        {
            // This is checking if the user changed the workspace                    
            if (w.Name.ToUpper() == "WSCURRENT")
            {
                // Load Ribbon/Menu again
                SetUpRibbon();
            }
        };

        MessageBox.Show("Removing LoadRibbonMenuOnIdle from the Idle Event");
        Application.Idle -= LoadRibbonMenuOnIdle;
    }

}


private static void SetUpRibbon()
{
var ribbonControl = ComponentManager.Ribbon;

var tab = ribbonControl.FindTab("Jacobs Tools");
if (tab != null)
{
// Tab already exists. This function shouldnt be running again. Remove the event and exit function
MessageBox.Show("Tab already exists.");
//Autodesk.AutoCAD.Ribbon.RibbonServices.RibbonPaletteSetCreated -= LoadRibbonMenuOnIdle;
return;
}

MessageBox.Show("Starting to create ribbon");
// Create tab
tab = new RibbonTab();
tab.Title = "Jacobs Tools";
tab.Id = tab.Title;

ribbonControl.Tabs.Add(tab);

var panelSources = new Dictionary<string, RibbonPanelSource>();
var contentLabGroupName = "Content Lab";
var settingsGroupName = "Settings";
var helpGroupName = "Help";
var defaultHelpUrl = new Uri(Path.Combine(Web.HelpUrl, "autocad-addin"));

// Button data
var buttonDataList = new[]
{
new ButtonData {
Name = "Content Lab",
Image = Resources.browser,
PanelName = contentLabGroupName,
Handler = new ContentBrowserCommandHandler(),
HelpSource = defaultHelpUrl,
},
// More buttons created.....
};

foreach (var buttonData in buttonDataList)
{
// Get or create panel source
RibbonPanelSource panelSource;
if (!panelSources.ContainsKey(buttonData.PanelName))
{
panelSource = new RibbonPanelSource
{
Title = buttonData.PanelName
};
panelSources[buttonData.PanelName] = panelSource;
}
else
{
panelSource = panelSources[buttonData.PanelName];
}

// Create button
var button = new RibbonButton();
button.Name = buttonData.Name;
button.Text = button.Name;
button.Description = buttonData.Tooltip;
button.ShowText = true;
button.ShowImage = true;
button.HelpSource = buttonData.HelpSource;

if (buttonData.Image != null)
button.LargeImage = Misc.BitmapToImageSource(buttonData.Image);

button.Size = RibbonItemSize.Large;
button.CommandHandler = buttonData.Handler;
button.Orientation = System.Windows.Controls.Orientation.Vertical;

// Add button to panel
panelSource.Items.Add(button);
}

// Add panels to tab
foreach (var panelSource in panelSources.Values)
tab.Panels.Add(new RibbonPanel
{
Source = panelSource
});

MessageBox.Show("Ribbon Loaded.");
}

 

0 REPLIES 0

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost