def get_datafile(reverse): global append_mode datafile = script.get_document_data_file("pyApex_Constraints", "pym") saved_list = [] if os.path.exists(datafile): if reverse == False: td = TaskDialog("Constraints") td.MainInstruction = "File with elements saved after previous run found.\nHow to deal with it?" td.AddCommandLink(TaskDialogCommandLinkId.CommandLink1, "Remove it and replace") td.AddCommandLink(TaskDialogCommandLinkId.CommandLink2, "Append new data") td.AllowCancellation = True taskDialogResult = td.Show() if taskDialogResult == TaskDialogResult.Cancel: return None, None elif taskDialogResult == TaskDialogResult.CommandLink1: append_mode = False else: append_mode = True if append_mode: f = open(datafile, 'r') saved_list = pickle.load(f) f.close() # remove duplicates ids = list(set(saved_list)) return datafile, ids
def dialogManager(): '''dialogbox to manage updater state from a ribbon button''' #scope when dialogManager is called doc = __revit__.ActiveUIDocument.Document # registering state app_dmu = UpdaterRegistry.IsUpdaterRegistered(myroomupdater.GetUpdaterId()) doc_dmu = UpdaterRegistry.IsUpdaterRegistered(myroomupdater.GetUpdaterId(), doc) # note : the global will be unregistered when the last document is unregistered # note2 : look at IsUpdaterEnabled and EnableUpdater/DisableUpdater too # note3 : enabled or not, an updater may be suspended by Revit for misbehaving # build the dialog box box = TaskDialog('Dynamic Model Updaters') box.MainInstruction = 'DoubleHeight Updater Manager' box.MainContent = '- Document Updater is :{0} Registered'.format( ' NOT' * (not doc_dmu)) box.MainContent += '\n- Global Updater is :{0} Registered'.format( ' NOT' * (not app_dmu)) # add command options if doc_dmu: box.AddCommandLink(TaskDialogCommandLinkId.CommandLink1, 'Disable document Updater') else: box.AddCommandLink(TaskDialogCommandLinkId.CommandLink2, 'Enable document Updater') if app_dmu: box.AddCommandLink(TaskDialogCommandLinkId.CommandLink3, 'Disable all documents Updater ') # box.FooterText = 'Add comments in the footer' # close button to abort box.CommonButtons = TaskDialogCommonButtons.Close # show the dialogbox and capture the answer answer = box.Show() # 1st option : disable updater for current document if answer == TaskDialogResult.CommandLink1: doc_unregister(doc) # 2nd option : register the current doc elif answer == TaskDialogResult.CommandLink2: doc_register(doc) # 3rd option : disable updater for all opened documents elif answer == TaskDialogResult.CommandLink3: global_unregister()
if i == ii == 0: __window__.Close() trans.RollBack() TaskDialog.Show("You are amazing! None of the Drafting Views or Sections on sheets were missing templates. You should celebrate.") sys.exit() # Get the application and document from external command data. # app = commandData.Application.Application; # activeDoc = commandData.Application.ActiveUIDocument.Document; # Creates a Revit task dialog to communicate information to the user. mainDialog = TaskDialog("SilmanApps") mainDialog.MainInstruction = "I recommend reviewing the results before keeping them." mainDialog.MainContent = "Click on the Revit icon on the taskbar and switch windows to view." # Add commmandLink options to task dialog mainDialog.AddCommandLink(Autodesk.Revit.UI.TaskDialogCommandLinkId.CommandLink1,"Undo changes?") mainDialog.AddCommandLink(Autodesk.Revit.UI.TaskDialogCommandLinkId.CommandLink2,"Keep Changes") # Set footer text. Footer text is usually used to link to the help document. mainDialog.FooterText = " " tResult = mainDialog.Show() # If the user clicks the second command link, a simple Task Dialog # created by static method shows information about the active document if Autodesk.Revit.UI.TaskDialogResult.CommandLink2 == tResult: trans.Commit() else: trans.RollBack()
dialog.FooterText = 'Footer Text' dialog.VerificationText = 'Verification Text' # dialog.ExpandedContent = expanded_content # Settings dialog.TitleAutoPrefix = False dialog.AllowCancellation = True # Add Button dialog.CommonButtons = TaskDialogCommonButtons.Ok | TaskDialogCommonButtons.Yes # Set Default Button dialog.DefaultButton = TaskDialogResult.None # Add Command Link dialog.AddCommandLink(TaskDialogCommandLinkId.CommandLink1, 'Command Button Text', 'Command Button Sub Text') dialog.AddCommandLink(TaskDialogCommandLinkId.CommandLink2, 'Command Button Text 2', 'Command Button Sub Text 2') result = dialog.Show() if result == TaskDialogResult.Ok: print('Dialog was OK') if result == TaskDialogResult.Yes: print('Dialog was Yes') if result == TaskDialogResult.Cancel: print('Dialog was Cancelled') if result == TaskDialogResult.CommandLink1: print('Button Was Pressed') if result == TaskDialogResult.CommandLink2: print('Button 2 Was Pressed')
# note : the global will be unregistered when the last document is unregistered # note2 : look at IsUpdaterEnabled and EnableUpdater/DisableUpdater too # note3 : enabled or not, an updater may be suspended by Revit for misbehaving # build the dialog box box = TaskDialog('Dynamic Model Updaters') box.MainInstruction = 'DoubleHeight Updater Manager' box.MainContent = '- Document Updater is :{0} Registered'.format(' NOT' * (not doc_dmu)) box.MainContent += '\n- Global Updater is :{0} Registered'.format(' NOT' * (not app_dmu)) # add command options if doc_dmu: box.AddCommandLink(TaskDialogCommandLinkId.CommandLink1, 'Disable document Updater') else : box.AddCommandLink(TaskDialogCommandLinkId.CommandLink2, 'Enable document Updater') if app_dmu: box.AddCommandLink(TaskDialogCommandLinkId.CommandLink3, 'Disable all documents Updater ') # box.FooterText = 'Add comments in the footer' # close button to abort box.CommonButtons = TaskDialogCommonButtons.Close # show the dialogbox and capture the answer answer = box.Show()
def window(): dialog = TaskDialog("Sheet Names to CSV") dialog.MainInstruction = 'Options' dialog.AddCommandLink(TaskDialogCommandLinkId.CommandLink1, 'Sheet Name and Number','') dialog.AddCommandLink(TaskDialogCommandLinkId.CommandLink2, 'Sheet Name Only', '') return dialog.Show()