|
| 1 | +""" |
| 2 | +Creates a TaskDialog |
| 3 | +
|
| 4 | +TESTED REVIT API: - |
| 5 | +
|
| 6 | +Author: Gui Talarico | github.com/gtalarico |
| 7 | +
|
| 8 | +This file is shared on www.revitapidocs.com |
| 9 | +For more information visit http://github.com/gtalarico/revitapidocs |
| 10 | +License: http://github.com/gtalarico/revitapidocs/blob/master/LICENSE.md |
| 11 | +""" |
| 12 | + |
| 13 | +# Results here: https://imgur.com/4DiPYfe |
| 14 | + |
| 15 | +from Autodesk.Revit.UI import (TaskDialog, TaskDialogCommonButtons, |
| 16 | + TaskDialogCommandLinkId, TaskDialogResult) |
| 17 | + |
| 18 | +title = 'Task Dialog Title' |
| 19 | +dialog = TaskDialog(title) |
| 20 | + |
| 21 | +# Properties |
| 22 | +dialog.MainInstruction = 'Text Header' |
| 23 | +dialog.MainContent = 'Text Content' |
| 24 | +dialog.FooterText = 'Footer Text' |
| 25 | +dialog.VerificationText = 'Verification Text' |
| 26 | +# dialog.ExpandedContent = expanded_content |
| 27 | + |
| 28 | +# Settings |
| 29 | +dialog.TitleAutoPrefix = False |
| 30 | +dialog.AllowCancellation = True |
| 31 | + |
| 32 | +# Add Button |
| 33 | +dialog.CommonButtons = TaskDialogCommonButtons.Ok | TaskDialogCommonButtons.Yes |
| 34 | + |
| 35 | +# Set Default Button |
| 36 | +dialog.DefaultButton = TaskDialogResult.None |
| 37 | + |
| 38 | +# Add Command Link |
| 39 | +dialog.AddCommandLink(TaskDialogCommandLinkId.CommandLink1, |
| 40 | + 'Command Button Text', |
| 41 | + 'Command Button Sub Text') |
| 42 | +dialog.AddCommandLink(TaskDialogCommandLinkId.CommandLink2, |
| 43 | + 'Command Button Text 2', |
| 44 | + 'Command Button Sub Text 2') |
| 45 | + |
| 46 | +result = dialog.Show() |
| 47 | + |
| 48 | +if result == TaskDialogResult.Ok: |
| 49 | + print('Dialog was OK') |
| 50 | +if result == TaskDialogResult.Yes: |
| 51 | + print('Dialog was Yes') |
| 52 | +if result == TaskDialogResult.Cancel: |
| 53 | + print('Dialog was Cancelled') |
| 54 | +if result == TaskDialogResult.CommandLink1: |
| 55 | + print('Button Was Pressed') |
| 56 | +if result == TaskDialogResult.CommandLink2: |
| 57 | + print('Button 2 Was Pressed') |
| 58 | +if dialog.WasVerificationChecked(): |
| 59 | + print('Verification was Checked') |
| 60 | + |
0 commit comments