
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Ok, this is absolutely doing my head in as I have searched for countless examples all of which seem to suggest I'm not doing anything wrong... Basically, I just want to control the visibility/usability of my external command. Everywhere I've read suggests:
namespace HERibbon { // [Transaction(TransactionMode.Manual)] [Regeneration(RegenerationOption.Manual)] public class Availability : IExternalCommandAvailability { public bool IsCommandAvailable(UIApplication uiApp, CategorySet catSet) { // if (catSet.IsEmpty) return true; // if (uiApp.ActiveUIDocument.Document.IsFamilyDocument) return false; // if (uiApp.ActiveUIDocument.Document.IsModifiable) return true; return true; } } class App : IExternalApplication { static void AddRibbonPanel(UIControlledApplication application) { // Create the ribbon tab String tabName = @"H&E Tools"; application.CreateRibbonTab(tabName); // Create the panels on that tab RibbonPanel rp_About = application.CreateRibbonPanel(tabName, "About"); // Get our installation path string thisAssemblyPath = Assembly.GetExecutingAssembly().Location; // Add to the About Panel // About PushButtonData pbData_About = new PushButtonData("About", "Info", thisAssemblyPath, "HETools.About"); // pbData_About.AvailabilityClassName = "HERibbon.Availability"; PushButton pb_About = rp_About.AddItem(pbData_About) as PushButton; pb_About.ToolTip = @"H&E Tools version info."; BitmapImage image_About = new BitmapImage(new Uri(@"C:\Program Files\HETools\src\about.ico")); pb_About.LargeImage = image_About; pb_About.Image = image_About; pb_About.AvailabilityClassName = "HERibbon.Availability"; } public Result OnStartup(UIControlledApplication application) { AddRibbonPanel(application); return Result.Succeeded; } public Result OnShutdown(UIControlledApplication application) { return Result.Succeeded; } } }
The commented out code are combos I've tried to get this thing to work.
The problem is when I select my tab on the ribbon when no document is open I get the following error:
Debug says the exception is thrown at the public bool IsCommandAvailable. If I comment out the class, my plugin works fine. Even with the exception, the plugins still work once a project is opened, however, I need to fix this. My main plugin is a workshare enabler that I obviously can't have being run in the family editor (for example).
I have literally tried copying and pasting this sample and I still get a null ref error. I started from thebuildingcoder's zerodoc and am getting the same exception. I am absolutely out of ideas... has something changed in 2019?
Solved! Go to Solution.