/*------------------------------------------------------------------------- * 功能描述:VersionManager * 作者:xulisong * 创建时间: 2019/1/16 15:47:21 * 版本号:v1.0 * -------------------------------------------------------------------------*/ using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Autodesk.RevitAddIns; namespace RevitVersion { /// /// 版本管理 /// public class VersionManager { static VersionManager() { Current = new VersionManager(); } public static VersionManager Current { get;private set; } /// /// 当前版本信息 /// public Version Version { get { #if R14 return Version.Revit2017; #elif R15 return Version.Revit2015; #elif R16 return Version.Revit2016; #elif R17 return Version.Revit2017; #elif R18 return Version.Revit2018; #endif } } public static List GetRevitProducts() { return RevitProductUtility.GetAllInstalledRevitProducts(); } private RevitProduct m_Product; public RevitProduct Product { get { if (m_Product == null) { var products = GetRevitProducts(); m_Product = products.FirstOrDefault(p => p.Version.ToString() == Version.ToString()); } return m_Product; } } } }