/* ============================================================================== * 功能描述:启动Revit时自定义菜单配置 * 创 建 者:SAGACLOUD * 创建日期:2017/8/30 * ==============================================================================*/ using Autodesk.Revit.UI; using SAGA.DotNetUtils; using SAGA.RevitUtils; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Windows.Media.Imaging; using System.Xml; using Autodesk.Windows; using SAGA.DotNetUtils.Extend; using SAGA.DotNetUtils.Others; using SAGA.RevitMenu.Addin; using RibbonItem = Autodesk.Revit.UI.RibbonItem; using RibbonPanel = Autodesk.Revit.UI.RibbonPanel; namespace SAGA.RevitMenu.Configuration { public class MenuConfig { /// /// 加载菜单 /// /// /// public static bool LoadMenus(UIControlledApplication application) { try { if (application.ActiveAddInId == null) { return false; } Guid gUID = application.ActiveAddInId.GetGUID(); string str = ""; if (gUID.ToString().ToUpper() == "EABBE53F-04A0-4D10-905F-FE4DB67E1F3C") { str = "TSBIM"; } if (str.Length == 0) { return false; } bool blnRevit = false; TszTabData[] configTabs = XmlMenuData.GetConfigTabs(application.ControlledApplication.VersionNumber, out blnRevit); if ((configTabs == null) || (configTabs.Length <= 0)) { MessageShow.Infomation("菜单加载错误:菜单配置文件异常"); return false; } //跟据权限对数据进行修饰 //XmlMenuDataWrapper.Wrapper(configTabs); bool flag2 = RevitRibbonOperate.ApplyConfigTabs(application, configTabs); return flag2; } catch (Exception exception) { if (exception.Message == "Too many tabs have been created by the API. Instead, you may add your Ribbon Panels to the Add-Ins tab.") { MessageShow.Infomation("启动的插件菜单过多,请勿全部勾选或卸载其它插件。"); } else { MessageShow.Show(exception, false, ""); } return false; } } /// /// 清除Addins文件 /// /// /// public static bool ClearAddInFile(UIControlledApplication application) { if (application.ActiveAddInId == null) { return false; } Guid guid = application.ActiveAddInId.GetGUID(); string strProductType = application.ControlledApplication.Product.ToString(); string versionNumber = application.ControlledApplication.VersionNumber; return RevitStartHelper.ClearAddInFile(guid, strProductType, versionNumber); } } }