下載app免費(fèi)領(lǐng)取會員
在RevitAPI里創(chuàng)建Tab有一個(gè)限制就是數(shù)量不能超過20個(gè)
Autodesk.Revit.Exceptions..::..InvalidOperationException Too many custom tabs have been created in this session. (Maximum is 20).
那有沒有可能創(chuàng)建第21個(gè)Tab呢?當(dāng)然是可以的
Type uiapp = typeof(UIApplication);
FieldInfo fielInfo = uiapp.GetField("m_ItemsNameDictionary", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance);
Dictionary<string, Dictionary<string, RibbonPanel>> dict = fielInfo.GetValue(null) as Dictionary<string, Dictionary<string, RibbonPanel>>;
if (dict.Count < 23)
{
UiCtrlApp.CreateRibbonTab(name);
}
else
{
RevitRibbonControl rvtControl = RevitRibbonControl.RibbonControl;
if (rvtControl.FindTab(name) != null)
{
throw new ArgumentException("tabName or panelName is Empty or the tab name duplicates the name of another tab in the Revit UI");
}
adWin.RibbonTabCollection tabs = rvtControl.Tabs;
int num = 0;
if (0 < tabs.Count)
{
do
{
adWin.RibbonTab ribbonTab = tabs[num];
if (ribbonTab.IsContextualTab || ribbonTab.Id == "Modify")
{
break;
}
num++;
}
while (num < tabs.Count);
}
adWin.RibbonTab ribbonTab2 = new adWin.RibbonTab();
ribbonTab2.Name = name;
ribbonTab2.Title = name;
ribbonTab2.Id = name;
rvtControl.Tabs.Insert(num, ribbonTab2);
dict.Add(name, new Dictionary<string, RibbonPanel>());
}
本文版權(quán)歸腿腿教學(xué)網(wǎng)及原創(chuàng)作者所有,未經(jīng)授權(quán),謝絕轉(zhuǎn)載。
上一篇:Revit如何自動生成圖紙目錄?
推薦專題