Revit二次开发入门——Task Dialogs


        TaskDialog mainDialog = new TaskDialog("Hello Revit");
        mainDialog.MainInstruction = "Hello ,Revit~";
        mainDialog.MainContent = "this sample shows how to use a Revit task dialog to communicate with the user.";

        mainDialog.AddCommandLink(TaskDialogCommandLinkId.CommandLink1,"View information about the Revit installation");
        mainDialog.AddCommandLink(TaskDialogCommandLinkId.CommandLink2,"View information about the active document");

        mainDialog.CommonButtons=TaskDialogCommonButtons.Close;
        mainDialog.DefaultButton=TaskDialogResult.Close;

        mainDialog.FooterText="<a href=\"http://usa.autodesk.com/adsk/servlet/index?\">"
            +"Click here for the Revit API Developer Center</a>";
        TaskDialogResult tResult = mainDialog.Show();

        if (TaskDialogResult.CommandLink1 == tResult)
        {
            TaskDialog dialog_CommandLink1= new TaskDialog("Revit Build Information");
            dialog_CommandLink1.MainInstruction="Revit Version Name is:"+app.VersionName+"\n"+
                "Revit Version Number is:"+app.VersionNumber+"\n"+"Revit Version Build is:"+app.VersionBuild;
            dialog_CommandLink1.Show();
        }

            else if (TaskDialogResult.CommandLink2==tResult)
            {
                TaskDialog.Show("Active Document Information","Active document:"+activeDoc.Title+"\n" +
                    "Active view name:"+activeDoc.ActiveView.Name);
            }
        return Result.Succeeded;
    }
    }

在Revit 附加工具中运行:
Revit二次开发入门——Task Dialogs_第1张图片
点击第一项,返回Revit版本号
Revit二次开发入门——Task Dialogs_第2张图片

以上是Revit开发中简单的TaskDialogs例子

你可能感兴趣的:(Revit-二次开发,Revit二次开发)