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.
Solved! Go to Solution.
Solved by DiningPhilosopher. Go to Solution.
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.
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.
@Anonymous 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.
@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.