Sometimes you need your add-in to operate only in the presence of a particular Update Release of Revit due to the presence of specific fixes or compatible APIs.
Properties of Application make it possible to check for specific versions of Revit. While the property VersionNumber will return a string representing the primary version number, the VersionBuild property will return the internal build number of the Autodesk Revit application.
Another useful property is the IsSubscriptionUpdate property. It will return true if this version of Revit is a subscription update. Subscription update releases may have additional APIs and functionality not available in the standard customer releases. Add-ins written to support standard Revit releases should be compatible with subscription updates, but add-ins written specifically targeting new features in subscription updates would not be compatible with the standard releases.
The following sample code demonstrates a technique to determine if the Revit version is any Update Release after the initial known Revit release.
Code Region: Use VersionBuild to identify if your add-in is compatible |
public void GetVersionInfo(Autodesk.Revit.ApplicationServices.Application app) { // 20110309_2315 is the datecode of the initial release of Revit 2012 if (app.VersionNumber == "2012" && String.Compare(app.VersionBuild, "20110309_2315") > 0) { TaskDialog.Show("Supported version", "This application supported in this version."); } else { TaskDialog dialog = new TaskDialog("Unsupported version."); dialog.MainIcon = TaskDialogIcon.TaskDialogIconWarning; dialog.MainInstruction = "This application is only supported in Revit 2012 UR1 and later."; dialog.Show(); } } |