在Revit的UIFramework.dll里有一个CommandUtility,里面有一个Execute(RibbonCommandItem btn)方法,
看起来像是一个调用Revit命令的方法,下面来测试一下,有一个问题是这个类不是public的所以调用要用反射
下面是个测试代码:
adWin.RibbonControl control = adWin.ComponentManager.Ribbon;
RibbonItemEnumerator itor = control.Tabs.First().Panels.ElementAt(1).Source.GetItemEnumerator();
adWin.RibbonCommandItem cmd = null;
while (itor.MoveNext())
{
cmd = itor.Current as adWin.RibbonCommandItem;
if (cmd != null)
{
break;
}
}
Type tp = typeof(ShortcutWindow).Assembly.GetTypes().First(m => m.FullName == "UIFramework.CommandUtility");
if (tp != null)
{
//MessageBox.Show("OK");
MethodInfo mi = tp.GetMethod("Execute");
mi.Invoke(null, new object[] { cmd});
}
//CollaborateWindow cw = new CollaborateWindow();
//cw.Show();
//ShortcutWindow sw = new ShortcutWindow();
//sw.Show();