-
-
Save ricaun/200a576c3baa45cba034ceedac1e708e to your computer and use it in GitHub Desktop.
Revit Command to test the Version and Defines
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Autodesk.Revit.Attributes; | |
using Autodesk.Revit.DB; | |
using Autodesk.Revit.UI; | |
using System; | |
using System.ComponentModel; | |
namespace RevitAddin | |
{ | |
#if DEBUG | |
[DisplayName("Revit\rDebug")] | |
#else | |
[DisplayName("Revit\rVersion")] | |
#endif | |
[Description("Show a Window with the Revit VersionName.")] | |
[Designer("/UIFrameworkRes;component/ribbon/images/revit.ico")] | |
[Transaction(TransactionMode.Manual)] | |
public class CommandVersion : IExternalCommand, IExternalCommandAvailability | |
{ | |
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elementSet) | |
{ | |
UIApplication uiapp = commandData.Application; | |
System.Windows.MessageBox.Show(uiapp.Application.VersionName, GetRevitVersion()); | |
return Result.Succeeded; | |
} | |
public bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories) | |
{ | |
return true; | |
} | |
public static string GetRevitVersion() | |
{ | |
#if Revit2017 || REVIT2017 | |
return "2017"; | |
#elif Revit2018 || REVIT2018 | |
return "2018"; | |
#elif Revit2019 || REVIT2019 | |
return "2019"; | |
#elif Revit2020 || REVIT2020 | |
return "2020"; | |
#elif Revit2021 || REVIT2021 | |
return "2021"; | |
#elif Revit2022 || REVIT2022 | |
return "2022"; | |
#elif Revit2023 || REVIT2023 | |
return "2023"; | |
#elif Revit2024 || REVIT2024 | |
return "2024"; | |
#elif Revit2025 || REVIT2025 | |
return "2025"; | |
#else | |
return "Undefined"; | |
#endif | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment