RevitUtils.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*-------------------------------------------------------------------------
  2. * 功能描述:RevitUtils
  3. * 作者:xulisong
  4. * 创建时间: 2019/7/29 9:08:18
  5. * 版本号:v1.0
  6. * -------------------------------------------------------------------------*/
  7. using System;
  8. using System.Collections.Generic;
  9. using System.IO;
  10. using System.Linq;
  11. using System.Text;
  12. using System.Threading.Tasks;
  13. using Autodesk.RevitAddIns;
  14. namespace ExportStart
  15. {
  16. public class RevitUtils
  17. {
  18. /// <summary>
  19. /// 获取Revit搜索dll路径
  20. /// </summary>
  21. /// <returns></returns>
  22. public static List<string> GetSearchPath()
  23. {
  24. #if DEBUG
  25. return RevitProductUtility.GetAllInstalledRevitProducts().Where(t => t.Name == "Revit 2017").Select(x => x.InstallLocation).ToList();
  26. #else
  27. return new List<string>(){GetRevitDllPath()};
  28. #endif
  29. }
  30. #region dll路径管理
  31. /// <summary>
  32. /// 获取RevitDll,所在目录
  33. /// </summary>
  34. /// <returns></returns>
  35. public static string GetRevitDllPath()
  36. {
  37. if (!string.IsNullOrWhiteSpace(m_RevitDllPath))
  38. {
  39. return m_RevitDllPath;
  40. }
  41. return Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"..\\RevitDlls");
  42. }
  43. private static string m_RevitDllPath;
  44. public static void SetRevitDllPath(string path)
  45. {
  46. m_RevitDllPath = path;
  47. }
  48. #endregion
  49. }
  50. }