Beispiel #1
0
        /// <summary>
        /// Command Entry Point
        /// </summary>
        /// <param name="commandData">Input argument providing access to the Revit application and documents</param>
        /// <param name="message">Return message to the user in case of error or cancel</param>
        /// <param name="elements">Return argument to highlight elements on the graphics screen if Result is not Succeeded.</param>
        /// <returns>Cancelled, Failed or Succeeded</returns>
        public Result Execute(ExternalCommandData commandData,
                              ref string message,
                              ElementSet elements)
        {
            try
            {
                // Version
                if (!commandData.Application.Application.VersionName.Contains("2018"))
                {
                    message = "This Add-In was built for Revit 2018, please contact CASE for assistance...";
                    return(Result.Failed);
                }

                // Construct and Display the form
                form_Main frm = new form_Main(commandData);
                frm.ShowDialog();

                // Return Success
                return(Result.Succeeded);
            }
            catch (Exception ex)
            {
                // Failure Message
                message = ex.Message;
                return(Result.Failed);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Report Groups by View
        /// </summary>
        /// <param name="commandData"></param>
        /// <param name="message"></param>
        /// <param name="elements"></param>
        /// <returns></returns>
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            try
            {
                // Version
                if (!commandData.Application.Application.VersionName.Contains("2020"))
                {
                    // Failure
                    using (TaskDialog td = new TaskDialog("Cannot Continue"))
                    {
                        td.TitleAutoPrefix = false;
                        td.MainInstruction = "Incompatible Version of Revit";
                        td.MainContent     = "This Add-In was built for Revit 2020, please contact CASE for assistance.";
                        td.Show();
                    }
                    return(Result.Cancelled);
                }

                // Settings
                clsSettings m_s = new clsSettings(commandData);
                if (m_s.ModelGroups.Count + m_s.DetailGroups.Count < 1)
                {
                    using (TaskDialog td = new TaskDialog("No Groups Found"))
                    {
                        td.TitleAutoPrefix = false;
                        td.MainInstruction = "No Groups Found";
                        td.Show();
                    }
                    return(Result.Cancelled);
                }

                // Form
                using (form_Main d = new form_Main(m_s))
                {
                    d.ShowDialog();
                }

                // Success
                return(Result.Succeeded);
            }
            catch (Exception ex)
            {
                // Failure
                message = ex.Message;
                return(Result.Failed);
            }
        }