下载app免费领取会员
在RevitAPI里创建Tab有一个限制就是数量不能超过20个
Autodesk.Revit.Exceptions..::..InvalidOperationException Too many custom tabs have been created in this session. (Maximum is 20).
那有没有可能创建第21个Tab呢?当然是可以的
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>());
}
本文版权归腿腿教学网及原创作者所有,未经授权,谢绝转载。
上一篇:Revit如何自动生成图纸目录?
下一篇:二次开发教程:C#键盘钩子