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

Ribbon Load on Startup - Another plugin causes it to fail

5 REPLIES 5
Reply
Message 1 of 6
jhdempsey
1061 Views, 5 Replies

Ribbon Load on Startup - Another plugin causes it to fail

Hi All

 

I am trying to load in a custom ribbon tab/pallete when AutoCAD loads.

 

I am aware that for various reasons, the ribbon might not have been loaded by the time my code is being run, so I used the code from the following forum post to register an event, so if the ribbon isn't loaded, it adds an event to fire when it is loaded, so my ribbon then loads.

https://forums.autodesk.com/t5/civil-3d-customization/how-to-initialize-custom-ribbon-bar-at-startup...

 

Our company uses ProjectWise as our document management system, so we have the ProjectWise Integration installed in AutoCAD and Civil3D.

 

If I disable the ProjectWise integration and restart AutoCAD, the below code works fine, and I see the message box saying "Loading DD Ribbon (Initialize) ..." when I startup AutoCAD, and the ribbon loads successfully.

 

However, if the ProjectWise integration is enabled and I restart AutoCAD, the ribbon doesn't get loaded, and I don't see any message boxes appear, so it looks like it's not even firing the initialization() function.

 

I have other plugins installed which load ribbons correctly, and I'm 99% confident they are creating their toolbar using code in a DLL file (i know for definite they are not loading a CUIX file)

 

Any ideas on how to fix this issue?

namespace DigitalDeliveryRibbon
{
    public class DDRibbon : Autodesk.AutoCAD.Runtime.IExtensionApplication
    {
        public void Initialize()
        {
            MessageBox.Show("Loading DD Ribbon (Initialize) ...");

            if (Autodesk.Windows.ComponentManager.Ribbon == null)
            {
                //load the custom Ribbon on startup, but at this point
                //the Ribbon control is not available, so register for
                //an event and wait
                Autodesk.Windows.ComponentManager.ItemInitialized += new EventHandler<RibbonItemEventArgs>(ComponentManager_ItemInitialized);
            }
            else
            {
                //the assembly was loaded using NETLOAD, so the ribbon
                //is available and we just create the ribbon
                LoadDDRibbon();
            }
        }

        private void ComponentManager_ItemInitialized(object sender, RibbonItemEventArgs e)
        {
            //now one Ribbon item is initialized, but the Ribbon control
            //may not be available yet, so check if before
            if (Autodesk.Windows.ComponentManager.Ribbon != null)
            {
                //ok, create Ribbon
                LoadDDRibbon();
                MessageBox.Show("Loading DD Ribbon via Event...");
                //and remove the event handler
                Autodesk.Windows.ComponentManager.ItemInitialized -= ComponentManager_ItemInitialized;
            }

        }

        [CommandMethod("CREATEDDRIBBON")]
        public void LoadDDRibbon()
        {
			// Code to create ribbon goes here
		}
	}
}
Labels (3)
5 REPLIES 5
Message 2 of 6

Try to use code:

 

    public class Commands : IExtensionApplication
    {
      public void Initialize()
      {
         /// ...
         Autodesk.AutoCAD.ApplicationServices.Application.Idle += new EventHandler(on_ApplicationIdle);
         /// ...
      }
     
      public void on_ApplicationIdle(object sender, EventArgs e)
      {
         /// ...
         addRibbonTab();
         /// ...
      }
     
      public void addRibbonTab()
      {
         /// ...
         RibbonControl rbCtrl = ComponentManager.Ribbon;
         if (rbCtrl != null)
         {
            LoadDDRibbon();
            MessageBox.Show("Loading DD Ribbon via Event...");
            Autodesk.AutoCAD.ApplicationServices.Application.Idle -= on_ApplicationIdle;
         }
      }
    }
     

 

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

Message 3 of 6

Im afraid the above code doesnt work 😞

 

It actually caused AutoCAD to hang for a long time during load. It took nearly 5 minutes for the ProjectWise login box to appear. After it did, the ribbon did not load, and I didn't see any of the message boxes

 

If I disable ProjectWise integration, the ribbon loads fine

 

Message 4 of 6

What doing if you manualy (with _NETLOAD) load yours dll-file after AutoCAD fully loaded with ProjectWise integrated?

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

Message 5 of 6

Because its in my PackageContents.xml file, i don't need to NETLOAD the file in

 

If I run the CREATEDDRIBBON command after the ProjectWise plugin has loaded, the ribbon loads fine.

 

I added a couple more message boxes in to see what's happening, and can confirm when I run the command, its calling the Initialize() code, the on_ApplicationIdle() function fires, then the addRibbonTab() function fires.

 

So for whatever reason, ProjectWIse is stopping the class from even being loaded at startup, since the Initialize() function is being called when I type in the command, which means its the first time the DLL and the class has been loaded?

Message 6 of 6


@jhdempsey wrote:

...So for whatever reason, ProjectWIse is stopping the class from even being loaded at startup, since the Initialize() function is being called when I type in the command, which means its the first time the DLL and the class has been loaded?


This question need to ask ProjectWIse tech support.

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

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

Post to forums  

Forma Design Contest


Autodesk Design & Make Report