- 在revit安装目录下找到 RevitAddInUtility.dll
- 在项目中引用
- 使用以下方法
using Autodesk.RevitAddIns;
/// <summary>
/// 获取指定版本的Revit安装目录
/// </summary>
/// <param name="revitVersion"></param>
/// <returns></returns>
public static string GetAllRevitInstallPath(RevitVersion revitVersion)
{
var revitProducts = GetAllRevitProducts();
RevitProduct revit = revitProducts.Find(x => (int)x.Version ==(int) revitVersion);
if (revit != null)
{
return revit.InstallLocation;
}
else
{
throw new Exception($"未安装{revitVersion}");
}
}
/// <summary>
/// 获取本机所有Revit安装信息
/// </summary>
/// <returns></returns>
public static List<RevitProduct> GetAllRevitProducts()
{
return RevitProductUtility.GetAllInstalledRevitProducts();
}