예제 #1
0
 /// <summary>
 /// Retrieve the a result from the possible results.  Will return null if the result does not have a corresponding choice.
 /// </summary>
 /// <param name="DialogResult">The value from the Task dialog.</param>
 /// <param name="Results">A dictionary of possible results.</param>
 /// <returns name="Result">The chosen result.</returns>
 public static object FilterResults(
     RevitUi.TaskDialogResult DialogResult,
     SynthDict Results
     )
 {
     return(SynthDict.Value(Results, DialogResult.ToString()));
 }
예제 #2
0
        /// <summary>
        /// Displays the task dialog box.
        /// </summary>
        /// <param name="TaskDialog">A Task dialog.</param>
        /// <param name="Toggle">A toggle used to re-display the Task Dialog.</param>
        /// <returns name="DialogResult">A TaskDialogResult based on the button or command link that was chosen.</returns>
        public static RevitUi.TaskDialogResult Show(DialogRevitTask TaskDialog,
                                                    [DefaultArgument("true")] bool Toggle)
        {
            RevitUi.TaskDialogResult tResult = TaskDialog.dialog.Show();

            TaskDialog.dialog.Dispose();
            return(tResult);
        }
예제 #3
0
        /// <summary>
        /// Creates a Revit Task Dialog.  The dialog can be configured in a variety of ways.  Additional options are available if you use the ByTitle method.
        /// </summary>
        /// <param name="Title">The Title of the dialog box.</param>
        /// <param name="Instructions">Instructions are written in a large font at the top of the dialog.</param>
        /// <param name="Content">Detailed content to be included.</param>
        /// <param name="FooterText">Footer text.  Useful for providing links to help content.</param>
        /// <param name="Buttons">A dictionary of the desired buttons.  Use the SpecifyButtons method to create the dictionary.</param>
        /// <param name="CommandLinks">A dictionary of the desired CommandLinks and associated text.  Use the SpecifyCommandLinks to create the dictionary.</param>
        /// <param name="Results">A dictionary of the possible results of the dialog.  Use the SpecifyResults method to create the dictionary.</param>
        /// <param name="Toggle">Resets the node so the dialog will reopen.</param>
        /// <returns name="Result">Returns the corresponding result based on the command link or button selected.  Will return null if the chosen button or command link has no result.  If now Results are input, the TaskDialogResult from the choice will be returned.</returns>
        public static object ByAllProperties(
            [DefaultArgument("\"Title\"")] string Title,
            [DefaultArgument("\"\"")] string Instructions,
            [DefaultArgument("\"\"")] string Content,
            [DefaultArgument("\"\"")] string FooterText,
            [DefaultArgument("null")] SynthDict Buttons,
            [DefaultArgument("null")] SynthDict CommandLinks,
            [DefaultArgument("null")] SynthDict Results,
            [DefaultArgument("true")] bool Toggle
            )
        {
            // Creates a Revit task dialog to communicate information to the user.
            DialogRevitTask dialog = new DialogRevitTask(Title);

            // Set the content areas of the dialog
            if (Instructions != "")
            {
                DialogRevitTask.SetInstructions(dialog, Instructions);
            }
            if (Content != "")
            {
                DialogRevitTask.SetContent(dialog, Content);
            }
            if (FooterText != "")
            {
                DialogRevitTask.SetFooterText(dialog, FooterText);
            }

            // Set the common buttons.  The default button will be the first button on the list.
            if (Buttons != null)
            {
                DialogRevitTask.AddCommonButtons(dialog, Buttons);
            }

            // If there are command links, add them to the dialog
            if (CommandLinks != null)
            {
                DialogRevitTask.AddCommandLinks(dialog, CommandLinks);
            }

            RevitUi.TaskDialogResult tResult = DialogRevitTask.Show(dialog, true);

            if (Results != null)
            {
                return(FilterResults(tResult, Results));
            }
            else
            {
                return(tResult);
            }
        }
예제 #4
0
        public void DeleteUnusedViews()
        {
            //set current document
            Autodesk.Revit.DB.Document curDoc = this.Application.ActiveUIDocument.Document;

            //set prefix of views to keep
            string viewPrefix = "working_";

            //create string for list of views
            string viewDeleteString = "";

            //alert user that this macro will delete views
            Autodesk.Revit.UI.TaskDialog userAlert = new TaskDialog("Warning");
            userAlert.MainInstruction = "This macro will delete all views that are not on a sheet or are not named with the '" + viewPrefix + "' prefix. Are you sure you want to proceed?";
            userAlert.AddCommandLink(Autodesk.Revit.UI.TaskDialogCommandLinkId.CommandLink1, "Yes");
            userAlert.AddCommandLink(Autodesk.Revit.UI.TaskDialogCommandLinkId.CommandLink2, "No");

            Autodesk.Revit.UI.TaskDialogResult userAlertResults = userAlert.Show();

            if (TaskDialogResult.CommandLink2 == userAlertResults)
            {
                //cancel sub
                return;
            }

            //delete views
            viewDeleteString = DeleteViews(curDoc, viewPrefix);

            //check if no views were deleted - if so then exit sub
            if (viewDeleteString == null)
            {
                return;
            }

            //delete views again to remove any dependent views
            viewDeleteString = viewDeleteString + DeleteViews(curDoc, viewPrefix);

            //alert user
            if (!string.IsNullOrEmpty(viewDeleteString))
            {
                TaskDialog.Show("Deleted Views", "Deleted the following views: " + viewDeleteString);
            }
        }