欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

revit 二次开发 按钮

程序员文章站 2024-03-13 10:30:39
...

生成一个按钮,同时鼠标放在按钮上,有提示信息

revit 二次开发 按钮

  [Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
    [Autodesk.Revit.Attributes.Journaling(Autodesk.Revit.Attributes.JournalingMode.NoCommandData)]
    public class ToolTip:IExternalCommand
    {
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            UIApplication uiapp = commandData.Application;
            UIDocument uidoc = uiapp.ActiveUIDocument;
            Document doc = uidoc.Document;

            IList<Reference> refList = uidoc.Selection.PickObjects(ObjectType.Element, "请选择构件");

            foreach (Reference f in refList)
            {
                TaskDialog.Show("提示", f.ElementId.ToString());
            }

            return Result.Succeeded;
        }
    }


    public class class2 : IExternalApplication
    {
        public Result OnStartup(UIControlledApplication application)
        {
            RibbonPanel ribbonPanel = application.CreateRibbonPanel("演示");

            PushButtonData buttonData=new PushButtonData("选择","选择",@"F:\BIM开发项目\RevitButtonTiptest\RevitButtonTiptest\bin\Debug\RevitButtonTiptest.dll","RevitButtonTiptest.ToolTip");
            PushButton pushbutton = ribbonPanel.AddItem(buttonData) as PushButton;

            pushbutton.ToolTip = "选择某个构件";

            return Result.Succeeded;
        }
        public Result OnShutdown(UIControlledApplication application)
        {
            return Result.Succeeded;
        }
    }

 

此外,为保证按钮的成功生成,需要在附件工具revit 二次开发 按钮

保存

同时在将addin文件的revit 二次开发 按钮

addin type=command 改成addin type=application