通过Application.GetRibbonPanels("Tab名称");得到RibbonPanel
通过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;
    }
}
from:http://revit.5d6d.com/thread-1370-1-1.html

相关文章:

  • 2021-06-19
  • 2022-01-03
  • 2021-09-08
  • 2022-12-23
  • 2021-05-25
  • 2022-12-23
  • 2021-11-18
  • 2021-04-21
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-02-03
  • 2022-01-10
  • 2021-07-04
  • 2022-12-23
  • 2021-12-06
相关资源
相似解决方案