Namespace:
Autodesk.Revit.UI
Assembly:
RevitAPIUI
(in RevitAPIUI.dll) Version: 17.0.0.0 (17.0.1090.0)
Since:
2011
Syntax
Remarks
There are two ways to create and show a task dialog to the user. The first option is to construct the TaskDialog, set its properties individually, and use the instance method Show() to show it to the user. The second is to use one of the static Show() methods to construct and show the dialog in one step. When you use the static methods only a subset of the options can be specified.
Please follow Revit standards to create task dialogs. The standards are listed in the remarks of each property or method.
Examples
// Get the application and document from external command data.
Application app = commandData.Application.Application;
Document activeDoc = commandData.Application.ActiveUIDocument.Document;
// Creates a Revit task dialog to communicate information to the user.
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."
+ "The command links below open additional task dialogs with more information.";
// Add commmandLink options to task dialog
mainDialog.AddCommandLink(TaskDialogCommandLinkId.CommandLink1,
"View information about the Revit installation");
mainDialog.AddCommandLink(TaskDialogCommandLinkId.CommandLink2,
"View information about the active document");
// Set common buttons and default button. If no CommonButton or CommandLink is added,
// task dialog will show a Close button by default
mainDialog.CommonButtons = TaskDialogCommonButtons.Close;
mainDialog.DefaultButton = TaskDialogResult.Close;
// Set footer text. Footer text is usually used to link to the help document.
mainDialog.FooterText =
"<a href=\"http://usa.autodesk.com/adsk/servlet/index?siteID=123112&id=2484975 \">"
+ "Click here for the Revit API Developer Center</a>";
TaskDialogResult tResult = mainDialog.Show();
// If the user clicks the first command link, a simple Task Dialog
// with only a Close button shows information about the Revit installation.
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();
}
// If the user clicks the second command link, a simple Task Dialog
// created by static method shows information about the active document
else if (TaskDialogResult.CommandLink2 == tResult)
{
TaskDialog.Show("Active Document Inforamtion",
"Active document: " + activeDoc.Title + "\n"
+ "Active view name: " + activeDoc.ActiveView.Name);
}
return Autodesk.Revit.UI.Result.Succeeded;
' Get the application and document from external command data.
Dim app As Application = commandData.Application.Application
Dim activeDoc As Document = commandData.Application.ActiveUIDocument.Document
' Creates a Revit task dialog to communicate information to the user.
Dim mainDialog As 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." + "The command links below open additional task dialogs with more information."
' Add commmandLink options to task dialog
mainDialog.AddCommandLink(TaskDialogCommandLinkId.CommandLink1, "View information about the Revit installation")
mainDialog.AddCommandLink(TaskDialogCommandLinkId.CommandLink2, "View information about the active document")
' Set common buttons and default button. If no CommonButton or CommandLink is added,
' task dialog will show a Close button by default
mainDialog.CommonButtons = TaskDialogCommonButtons.Close
mainDialog.DefaultButton = TaskDialogResult.Close
' Set footer text. Footer text is usually used to link to the help document.
mainDialog.FooterText = "<a href=""http://usa.autodesk.com/adsk/servlet/index?siteID=123112&id=2484975 "">" + "Click here for the Revit API Developer Center</a>"
Dim tResult As TaskDialogResult = mainDialog.Show()
' If the user clicks the first command link, a simple Task Dialog
' with only a Close button shows information about the Revit installation.
If TaskDialogResult.CommandLink1 = tResult Then
Dim dialog_CommandLink1 As New TaskDialog("Revit Build Information")
dialog_CommandLink1.MainInstruction = "Revit Version Name is: " + app.VersionName + vbLf + "Revit Version Number is: " + app.VersionNumber + vbLf + "Revit Version Build is: " + app.VersionBuild
dialog_CommandLink1.Show()
' If the user clicks the second command link, a simple Task Dialog
' created by static method shows information about the active document
ElseIf TaskDialogResult.CommandLink2 = tResult Then
TaskDialog.Show("Active Document Inforamtion", "Active document: " + activeDoc.Title + vbLf + "Active view name: " + activeDoc.ActiveView.Name)
End If
Return Autodesk.Revit.UI.Result.Succeeded