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

Commands didn't work if I open file by double click

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
pva75
604 Views, 4 Replies

Commands didn't work if I open file by double click

I made my plug-in for Autocad 2012.

I register my plug-in in registry and so it's autoloaded.

 

If I open Autocad I saw my toolbar, my message from IExtensionApplication.Initialize and all my commands (marked as [assembly: CommandClass) works fine. No problem.


BUT! If I open autocad file by double click - autocad opened. Now I saw my toolbar, saw my message from Initialize!
But any commands didn't work. Autocad said that command is unknown. What can be a problem? My be in Autocad version? I have student version and startup message about it.

 

Thanks,

Pavel.

4 REPLIES 4
Message 2 of 5
DiningPhilosopher
in reply to: pva75

This is one of the most frustrating aspects of AutoCAD's managed API. There are quite a few reasons why commands are not registered, but usually it is due to an exception being thrown in IExtensionApplication.Initialize().

 

You should always wrap all of the code in that method inside a try/catch block, and in the latter show a message on the command line or via some other means, to let you know what happened.

Message 3 of 5
pva75
in reply to: DiningPhilosopher

Dear DiningPhilosopher,

 

You are absolutely right. I had exception in Init because in first case Acad execute RIBBON command before open file, but in second Init was before RIBBON. So no RIBBON in Init and exception in this block.

 

Now all works fine!

 

Thank you!

Pavel.

Message 4 of 5
DiningPhilosopher
in reply to: pva75


@pva75 wrote:

Dear DiningPhilosopher,

 

You are absolutely right. I had exception in Init because in first case Acad execute RIBBON command before open file, but in second Init was before RIBBON. So no RIBBON in Init and exception in this block.

 

Now all works fine!

 

Thank you!

Pavel.


When working with the ribbon, I don't assume that it will appear when AutoCAD starts. The user might not have it visible, and can show it at any time. What I usually do is first check to see if the Ribbon is created using RibbonServices.RibbonPaletteSet. If it is null, the ribbon isn't visible, so I add a handler to the RibbonServices.RibbonPaletteSetCreated event. In the handler of that event, the ribbon has not been initialized yet, so I add another handler to the RibbonPaletteSet's Loaded event, which will fire after the ribbon has been fully initialized.

Message 5 of 5
pva75
in reply to: DiningPhilosopher


@DiningPhilosopher wrote:

When working with the ribbon, I don't assume that it will appear when AutoCAD starts. The user might not have it visible, and can show it at any time. What I usually do is first check to see if the Ribbon is created using RibbonServices.RibbonPaletteSet. If it is null, the ribbon isn't visible, so I add a handler to the RibbonServices.RibbonPaletteSetCreated event. In the handler of that event, the ribbon has not been initialized yet, so I add another handler to the RibbonPaletteSet's Loaded event, which will fire after the ribbon has been fully initialized.



Sorry, but I can't find RibbonServices class and events.

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