public static string GetRegistryKey(RevitVersion revitVersion, string keyName) { string value = ""; string keyAddress = ""; switch (revitVersion) { case RevitVersion.Revit2013: keyAddress = keyAddress2013; break; case RevitVersion.Revit2014: keyAddress = keyAddress2014; break; case RevitVersion.Revit2015: keyAddress = keyAddress2015; break; } RegistryKey registryKey = Registry.CurrentUser.OpenSubKey(keyAddress, true); if (null != registryKey) { string[] valueNames = registryKey.GetValueNames(); if (valueNames.Contains(keyName)) { value = registryKey.GetValue(keyName).ToString(); } } return(value); }
public static void SetRegistryKey(RevitVersion revitVersion, string keyName, object value) { try { string keyAddress = ""; switch (revitVersion) { case RevitVersion.Revit2013: keyAddress = keyAddress2013; break; case RevitVersion.Revit2014: keyAddress = keyAddress2014; break; case RevitVersion.Revit2015: keyAddress = keyAddress2015; break; } RegistryKey registryKey = Registry.CurrentUser.OpenSubKey(keyAddress, true); if (null == registryKey) { registryKey = Registry.CurrentUser.CreateSubKey(keyAddress); } registryKey.SetValue(keyName, value); } catch (Exception ex) { string message = ex.Message; } }
/// <summary> /// 指定Revit版本获取Revit安装路径. /// </summary> private static string GetRevitInstallationPath(RevitVersion version) { var product = Autodesk.RevitAddIns.RevitProductUtility.GetAllInstalledRevitProducts().FirstOrDefault(m => m.Version == version); if (product == null) { return(string.Empty); } return(product.InstallLocation); }
public static bool IsRevitVersionInstalled(RevitVersion revitVersion) { LoggingService.LogInfo("Checking for Revit installations"); var addinFolder = GetRevitAddinFolderLocation(revitVersion); var exists = Directory.Exists(addinFolder); var status = exists ? "This version of Revit does exist" : "This version of Revit doesn't exist"; LoggingService.LogInfo(status); return(exists); }
private bool CopyAddInFiles(RevitVersion version) { bool copied = false; try { string versionNumber = ""; string addInPath = ""; switch (version) { case RevitVersion.Revit2013: versionNumber = "2013"; addInPath = addInPath2013; break; case RevitVersion.Revit2014: versionNumber = "2014"; addInPath = addInPath2014; break; case RevitVersion.Revit2015: versionNumber = "2015"; addInPath = addInPath2015; break; } string sourceDirectory = dataDirectory + "\\" + versionNumber; if (ApplicationDeployment.IsNetworkDeployed) { foreach (string fileName in filesDictionary.Keys) { string filePath = filesDictionary[fileName]; File.Copy(sourceDirectory + fileName, addInPath + filePath, true); } } copied = true; } catch (Exception ex) { MessageBox.Show("Failed to copy addIn files.\n" + ex.Message, "Copy AddIn Files", MessageBoxButton.OK, MessageBoxImage.Warning); } return(copied); }
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()); } }
/// <summary> /// Initializes a new instance of the <see cref="BasicFileInfo"/> class. /// </summary> /// <param name="version">The string representation of Revit version.</param> /// <exception cref="ArgumentException"> /// The following version must be a non-empty string, castable to int /// or /// Failed to parse the version /// </exception> internal BasicFileInfo(string version) { if (string.IsNullOrWhiteSpace(version) || !int.TryParse(version, out int versionInt)) { throw new ArgumentException($"The following {nameof(version)} must be a non-empty string, castable to int"); } // Revit file has 2008 format or earlier if (versionInt > 2000 && versionInt < 2009) { versionInt = 2009; } if (!Enum.IsDefined(typeof(RevitVersion), versionInt)) { throw new ArgumentException($"Failed to parse the version {nameof(version)}"); } Version = (RevitVersion)versionInt; }
public static string GetRevitAddinFolderLocation(RevitVersion version) { LoggingService.LogInfo("Searching for Revit addin locations..."); switch (version) { case RevitVersion.V2018: return(Revit2018AddinLocation); case RevitVersion.V2019: return(Revit2019AddinLocation); case RevitVersion.V2020: return(Revit2020AddinLocation); default: case RevitVersion.Unknown: var exception = new Exception("Unknown version"); LoggingService.LogError("Couldn't identify this version of Revit", exception); throw exception; } }
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); }
public static string GetLabelForRevitVersion(RevitVersion revitVersion) { var label = Enum.GetName(typeof(RevitVersion), revitVersion); return(label ?? ""); }
/// <summary> /// Creates an instances. /// </summary> /// <param name="version"></param> /// <returns></returns> public static RevitContext CreateInstance(RevitVersion version) { _version = version.ToString().Replace("Revit", string.Empty); return(SingletonFactory <RevitContext> .CreateInstance()); }
public static void CreateAddinManifest(RevitVersion revitVersion, string directory) { RevitAddInManifest revitManifest = new RevitAddInManifest(); FileInfo fileInfo = new FileInfo(Path.Combine()); }