学习地址:https://www.bilibili.com/video/BV1mf4y1S72o?p=13
TaskDialog任务对话框
任务对话框的控件
任务对话框
任务对话框执行结果
实例练习一
using System; using System.Collections.Generic; using System.Linq; using System.Text; using Autodesk.Revit.UI; using Autodesk.Revit.DB; using Autodesk.Revit.ApplicationServices; using Autodesk.Revit.Attributes; using System.Windows.Forms; using Autodesk.Revit.UI.Selection; using Autodesk.Revit.UI.Events; namespace RevitDevTV { /// <summary> /// 任务对话框练习 /// </summary> [TransactionAttribute(TransactionMode.Manual)] [RegenerationAttribute(RegenerationOption.Manual)] public class Task : IExternalCommand { public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { Autodesk.Revit.ApplicationServices.Application app = commandData.Application.Application; TaskDialog mainDialog = new TaskDialog("is BIM模术师"); mainDialog.MainInstruction = "产品使用说明"; //设置主要说明 mainDialog.MainContent = "is BIM模术师是基于Autodesk Revit软件的本地化功能插件集"; //设置详细内容 mainDialog.ExpandedContent = "可用于建筑、结构、水电以及暖通等专业中"; //隐藏的内容,显示更多的内容 mainDialog.AddCommandLink(TaskDialogCommandLinkId.CommandLink1,"查看当前Revit版本信息"); //为命令对话框添加命令链接 mainDialog.AddCommandLink(TaskDialogCommandLinkId.CommandLink2, "查看模术师产品信息"); mainDialog.CommonButtons = TaskDialogCommonButtons.Ok | TaskDialogCommonButtons.Cancel; //设置普通按钮和默认按钮 mainDialog.VerificationText = "不再显示该信息"; //设置不再显示信息栏 //设置文字消息,一般一个链接 mainDialog.FooterText = "<a href="www.baidu.com">"+"百度一下</a>"; //=======显示任务对话框,并取得返回值 TaskDialogResult tResult = mainDialog.Show(); if (tResult == TaskDialogResult.CommandLink1) { TaskDialog dialog_command_link1 = new TaskDialog("版本信息"); dialog_command_link1.MainInstruction = "版本名:" + app.VersionName + " " + "版本号:" + app.VersionNumber; dialog_command_link1.Show(); } else if (tResult == TaskDialogResult.CommandLink2) { TaskDialog.Show("模术师产品介绍","isBIM魔术师是一个全过程、全专业的高效解决方案"); } return Result.Succeeded; } } }