使用Revit API Ribbon控件
通过Application.GetRibbonPanels("Tab名称");得到RibbonPanel通过IList<RibbonItem> listItem = ribbonPanel.GetItems();得到Panel中的控件
//得到Ribbon控件的值
public class cmdTest : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string messages, ElementSet elements)
{
UIApplication uiApp = commandData.Application;
Document doc = uiApp.ActiveUIDocument.Document;
Selection sel = uiApp.ActiveUIDocument.Selection;
Transaction ts = new Transaction(doc, "http://revit.5d6d.com");
ts.Start();
RibbonPanel ribbonPanel = null;
List<RibbonPanel> listPanel = commandData.Application.GetRibbonPanels("Tab名称");
foreach (RibbonPanel panel in listPanel)
{
if (panel.Name == "RibbonPanel名称")//RibbonPanel的Name
{
ribbonPanel = panel;
break;
}
}
//间距
TextBox textBox = null;
IList<RibbonItem> listItem = ribbonPanel.GetItems();
foreach (RibbonItem item in listItem)
{
if (item.Name == "txtDis")//Ribbon的Name属性
{
textBox = item as TextBox;
}
}
TaskDialog.Show("txt", textBox.Value.ToString());
ts.Commit();
return Result.Succeeded;
}
}
增加控件比较简单
splitButton.AddPushButton(pushButtonData);
去除控件,没有对应的方法。可以先隐藏:
splitButton.CurrentButton.Visible = false;
然后设置当前
splitButton.CurrentButton = defaultPushButton;
如果不这样设置,效果类似pushButton.Enabled=false;
另外一个小知识:
与Insert()对应有个Erase();
uiDoc.Selection.Elements.Erase();
SelElementSet.Erase();
from:http://revit.5d6d.com/thread-1373-1-1.html
路过!!!
帮顶……
页:
[1]