예제 #1
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            if (!RevitVersion.GetInstalledRevitVersions().Any())
            {
                var errorMessage = new StringBuilder();
                errorMessage.AppendLine("ERROR: Could not detect the BatchRvt addin for any version of Revit installed on this machine!");
                errorMessage.AppendLine();
                errorMessage.AppendLine("You must first install the BatchRvt addin for at least one version of Revit.");

                BatchRvtGuiForm.ShowErrorMessageBox(errorMessage.ToString());
            }
            else
            {
                Application.Run(new BatchRvtGuiForm());
            }
        }
        private IEnumerable <IUIConfigItem> GetUIConfigItems()
        {
            var iuConfigItems = new IUIConfigItem[] {
                // General Task Script settings
                new UIConfigItem(
                    () => {
                    this.taskScriptTextBox.Text = this.Settings.TaskScriptFilePath.GetValue();
                    this.showMessageBoxOnTaskScriptErrorCheckBox.Checked = this.Settings.ShowMessageBoxOnTaskScriptError.GetValue();
                },
                    () => {
                    this.Settings.TaskScriptFilePath.SetValue(this.taskScriptTextBox.Text);
                    this.Settings.ShowMessageBoxOnTaskScriptError.SetValue(this.showMessageBoxOnTaskScriptErrorCheckBox.Checked);
                }
                    ),

                // Revit File List settings
                new UIConfigItem(
                    () => { this.revitFileListTextBox.Text = this.Settings.RevitFileListFilePath.GetValue(); },
                    () => { this.Settings.RevitFileListFilePath.SetValue(this.revitFileListTextBox.Text); }
                    ),

                // Data Export settings
                new UIConfigItem(
                    () => {
                    this.enableDataExportCheckBox.Checked = this.Settings.EnableDataExport.GetValue();
                    this.dataExportFolderTextBox.Text     = this.Settings.DataExportFolderPath.GetValue();
                    UpdateDataExportControls();
                },
                    () => {
                    this.Settings.EnableDataExport.SetValue(this.enableDataExportCheckBox.Checked);
                    this.Settings.DataExportFolderPath.SetValue(this.dataExportFolderTextBox.Text);
                }
                    ),

                // Pre-processing Script settings
                new UIConfigItem(
                    () => {
                    this.executePreProcessingScriptCheckBox.Checked = this.Settings.ExecutePreProcessingScript.GetValue();
                    this.preProcessingScriptTextBox.Text            = this.Settings.PreProcessingScriptFilePath.GetValue();
                    UpdatePreProcessingScriptControls();
                },
                    () => {
                    this.Settings.ExecutePreProcessingScript.SetValue(this.executePreProcessingScriptCheckBox.Checked);
                    this.Settings.PreProcessingScriptFilePath.SetValue(this.preProcessingScriptTextBox.Text);
                }
                    ),

                // Post-processing Script settings
                new UIConfigItem(
                    () => {
                    this.executePostProcessingScriptCheckBox.Checked = this.Settings.ExecutePostProcessingScript.GetValue();
                    this.postProcessingScriptTextBox.Text            = this.Settings.PostProcessingScriptFilePath.GetValue();
                    UpdatePostProcessingScriptControls();
                },
                    () => {
                    this.Settings.ExecutePostProcessingScript.SetValue(this.executePostProcessingScriptCheckBox.Checked);
                    this.Settings.PostProcessingScriptFilePath.SetValue(this.postProcessingScriptTextBox.Text);
                }
                    ),

                // Central File Processing settings
                new UIConfigItem(
                    () => {
                    this.detachFromCentralRadioButton.Checked = (this.Settings.CentralFileOpenOption.GetValue() == BatchRvt.CentralFileOpenOption.Detach);
                    this.createNewLocalRadioButton.Checked    = (this.Settings.CentralFileOpenOption.GetValue() == BatchRvt.CentralFileOpenOption.CreateNewLocal);
                    this.deleteLocalAfterCheckBox.Checked     = this.Settings.DeleteLocalAfter.GetValue();
                    this.discardWorksetsCheckBox.Checked      = this.Settings.DiscardWorksetsOnDetach.GetValue();
                    UpdateCentralFileProcessingControls();
                },
                    () => {
                    this.Settings.CentralFileOpenOption.SetValue(
                        this.createNewLocalRadioButton.Checked ?
                        BatchRvt.CentralFileOpenOption.CreateNewLocal :
                        BatchRvt.CentralFileOpenOption.Detach
                        );
                    this.Settings.DeleteLocalAfter.SetValue(this.deleteLocalAfterCheckBox.Checked);
                    this.Settings.DiscardWorksetsOnDetach.SetValue(this.discardWorksetsCheckBox.Checked);
                }
                    ),

                // Revit Session settings
                new UIConfigItem(
                    () => {
                    this.useSeparateRevitSessionRadioButton.Checked = (this.Settings.RevitSessionOption.GetValue() == BatchRvt.RevitSessionOption.UseSeparateSessionPerFile);
                    this.useSameRevitSessionRadioButton.Checked     = (this.Settings.RevitSessionOption.GetValue() == BatchRvt.RevitSessionOption.UseSameSessionForFilesOfSameVersion);
                    var processingTimeOutInMinutes = this.Settings.ProcessingTimeOutInMinutes.GetValue();
                    if (processingTimeOutInMinutes < 0)
                    {
                        processingTimeOutInMinutes = 0;
                    }
                    this.perFileProcessingTimeOutCheckBox.Checked = processingTimeOutInMinutes > 0;
                    this.timeOutNumericUpDown.Value = processingTimeOutInMinutes;
                    UpdateRevitSessionControls();
                },
                    () => {
                    this.Settings.RevitSessionOption.SetValue(
                        this.useSameRevitSessionRadioButton.Checked ?
                        BatchRvt.RevitSessionOption.UseSameSessionForFilesOfSameVersion :
                        BatchRvt.RevitSessionOption.UseSeparateSessionPerFile
                        );

                    var processingTimeOutInMinutes = (int)this.timeOutNumericUpDown.Value;
                    if (processingTimeOutInMinutes < 0)
                    {
                        processingTimeOutInMinutes = 0;
                    }

                    this.Settings.ProcessingTimeOutInMinutes.SetValue(this.perFileProcessingTimeOutCheckBox.Checked ? processingTimeOutInMinutes : 0);
                }
                    ),

                // Revit Processing settings
                new UIConfigItem(
                    () => {
                    this.enableBatchProcessingCheckBox.Checked           = (this.Settings.RevitProcessingOption.GetValue() == BatchRvt.RevitProcessingOption.BatchRevitFileProcessing);
                    this.enableSingleRevitTaskProcessingCheckBox.Checked = (this.Settings.RevitProcessingOption.GetValue() == BatchRvt.RevitProcessingOption.SingleRevitTaskProcessing);
                    UpdateRevitProcessingControls();
                },
                    () => {
                    this.Settings.RevitProcessingOption.SetValue(
                        this.enableSingleRevitTaskProcessingCheckBox.Checked ?
                        BatchRvt.RevitProcessingOption.SingleRevitTaskProcessing :
                        BatchRvt.RevitProcessingOption.BatchRevitFileProcessing
                        );
                }
                    ),

                // Single Revit Task Processing settings
                new UIConfigItem(
                    () => {
                    Populate(
                        this.singleRevitTaskRevitVersionComboBox,
                        RevitVersion.GetInstalledRevitVersions().Select(RevitVersion.GetRevitVersionText),
                        RevitVersion.GetRevitVersionText(this.Settings.SingleRevitTaskRevitVersion.GetValue())
                        );
                },
                    () => {
                    this.Settings.SingleRevitTaskRevitVersion.SetValue(
                        RevitVersion.GetSupportedRevitVersion(this.singleRevitTaskRevitVersionComboBox.SelectedItem as string)
                        );
                }
                    ),

                // Batch Revit File Processing settings
                new UIConfigItem(
                    () => {
                    this.useFileRevitVersionRadioButton.Checked     = (this.Settings.RevitFileProcessingOption.GetValue() == BatchRvt.RevitFileProcessingOption.UseFileRevitVersionIfAvailable);
                    this.useSpecificRevitVersionRadioButton.Checked = (this.Settings.RevitFileProcessingOption.GetValue() == BatchRvt.RevitFileProcessingOption.UseSpecificRevitVersion);
                    this.useMinimumAvailableVersionCheckBox.Checked = this.Settings.IfNotAvailableUseMinimumAvailableRevitVersion.GetValue();
                    Populate(
                        this.specificRevitVersionComboBox,
                        RevitVersion.GetInstalledRevitVersions().Select(RevitVersion.GetRevitVersionText),
                        RevitVersion.GetRevitVersionText(this.Settings.BatchRevitTaskRevitVersion.GetValue())
                        );
                    UpdateRevitFileProcessingControls();
                },
                    () => {
                    this.Settings.RevitFileProcessingOption.SetValue(
                        this.useSpecificRevitVersionRadioButton.Checked ?
                        BatchRvt.RevitFileProcessingOption.UseSpecificRevitVersion :
                        BatchRvt.RevitFileProcessingOption.UseFileRevitVersionIfAvailable
                        );
                    this.Settings.IfNotAvailableUseMinimumAvailableRevitVersion.SetValue(this.useMinimumAvailableVersionCheckBox.Checked);
                    this.Settings.BatchRevitTaskRevitVersion.SetValue(
                        RevitVersion.GetSupportedRevitVersion(this.specificRevitVersionComboBox.SelectedItem as string)
                        );
                }
                    ),

                // Show Advanced setting
                new UIConfigItem(
                    () => {
                    this.showAdvancedSettingsCheckBox.Checked = this.Settings.ShowAdvancedSettings.GetValue();
                    UpdateAdvancedSettings();
                },
                    () => {
                    this.Settings.ShowAdvancedSettings.SetValue(this.showAdvancedSettingsCheckBox.Checked);
                }
                    ),
            };

            return(iuConfigItems);
        }