Revit禁用RibbonPanel

通过委托实现点击选项卡后禁用选项卡功能,关闭功能后启用选项卡功能

在A项目中定义一个RightMenuFunctions类

public class RightMenuFunctions
{
    public static Func<string> EnabledTrue;
}

在TheCommand,execute中

public Result Execute(
     ExternalCommandData commandData,
     ref string message,
     ElementSet elements)
{
     InFunCtions();
}

定义InFunCtions方法

public static void InFunCtions()
{ A.RightMenuFunctions.EnabledTrue = EnabledTrue; }

定义禁用选项卡方法

public static string EnabledTrue()
{
    List<RibbonPanel> list = uiapp.GetRibbonPanels("RibbonPanelName");
    RibbonPanel rp = list[0];
    rp.Enabled = true;
    return "";
}

在A项目MainWindow中添加Closing事件

RightMenuFunctions.EnabledTrue();

 

posted @ 2017-01-11 18:13  苏州城外的微笑  阅读(644)  评论(0编辑  收藏  举报