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

Autoloader problem

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
kob4lt
1373 Views, 5 Replies

Autoloader problem

I have some kind of application that have local command energo and it have IExtensionApplication method to call method

that creates Ribbon for application

 

Now, I created my directory bundle for autoloader and if I start AutoCAD and then copy my directory to AuplicationPlugins directory it runs perfectly and correct. Then, if I restart autocad, my ribbon tab is not showing, if i type energo it's says unknown command

 

What am I doing wrong?

 

And yes, APPAUTOLOAD sys variable is set to 14

5 REPLIES 5
Message 2 of 6
augusto.goncalves
in reply to: kob4lt

Hi,

 

Are you trying to modify the ribbon during Initialize method? If so, that may not be possible as the ribbon is not yet available for modifications....the suggestion could be register for an event, then create the ribbon later.

 

>>>>

        public void 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
                createRibbon();
            }
        }

<<<<

 

Regards,


Augusto Goncalves

Autodesk Developer Network

Regards,



Augusto Goncalves
Twitter @augustomaia
Autodesk Developer Network
Message 3 of 6
kob4lt
in reply to: augusto.goncalves

You where right about ribbon inicialization BUT for some unknown reason autocad is invoking several times method "

 public void Initialize()" from IExtensionApp interface. I dont know how is this posible but when I ran your code, my ribbon tab was created like 10 times.

Because of that I added this line of code

void ComponentManager_ItemInitialized(object sender, RibbonItemEventArgs e)
        {
            if (ComponentManager.Ribbon.FindTab("idEnergometan") == null)
                Pocetna.MojRibbon();
        }

 

 

 

Message 4 of 6
augusto.goncalves
in reply to: kob4lt

Hi,

 

Yes, this is correct...I forgot the second half of the solution: remove the event handler after the ribbon is created 🙂

 

>>>>

        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
                createRibbon();
                //and remove the event handler
                Autodesk.Windows.ComponentManager.ItemInitialized -=
                    new EventHandler<RibbonItemEventArgs>(ComponentManager_ItemInitialized);
            }
        }

<<<<

 

Regards,

Augusto Goncalves

Autodesk Developer Network

Regards,



Augusto Goncalves
Twitter @augustomaia
Autodesk Developer Network
Message 5 of 6
kob4lt
in reply to: augusto.goncalves

Thank you for this

 

But, can you explain why Ribbon object is more times initialized

Message 6 of 6
vladeck-talen
in reply to: kob4lt

ItemInitialized event is called multiple times for each ribbon item created (so it is not ribbon event, rather ribbon item initialization event)... if you have 10 ribbon tabs in your ACAD, there will be 10 calls to your handler. That's why it is so important to catch just the first one and remove event handler, as at that point you have a valid RibbonControl.

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