Revit API得到Ribbon控件
通过Application.GetRibbonPanels("Tab名称");得到RibbonPanel
from:http://revit.5d6d.com/thread-1370-1-1.html
通过IList<RibbonItem> listItem = ribbonPanel.GetItems();得到Panel中的控件
//得到Ribbon控件的值
[TransactionAttribute(Autodesk.Revit.Attributes.TransactionMode.Manual)]
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;
}
}
[TransactionAttribute(Autodesk.Revit.Attributes.TransactionMode.Manual)]
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;
}
}
我这个博客废弃不用了,今天想寻找外链的时候,突然想到这个博客权重很高。
有需要免费外链的,留言即可,我准备把这个博客变成免费的友情链接站点。