RevitUtils.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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 SAGA.DotNetUtils.Revit;
  12. namespace ExportStart
  13. {
  14. public class RevitUtils
  15. {
  16. /// <summary>
  17. /// 获取Revit搜索dll路径
  18. /// </summary>
  19. /// <returns></returns>
  20. public static List<string> GetSearchPath()
  21. {
  22. //选择版本时,预先将版本信息写在RevitFileVision.txt文件中,读取版本号
  23. var vision = File.ReadAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, StarterConst.RevitFileVisionFile));
  24. var revitVision = $"{vision}";
  25. return SAGA.DotNetUtils.Revit.RevitProductUtility.GetAllInstalledRevitProducts().Where(t => t.Item1==(revitVision)).Select(t => t.Item2).ToList();
  26. #if DEBUG
  27. #else
  28. return new List<string>(){GetRevitDllPath()};
  29. #endif
  30. }
  31. #region dll路径管理
  32. /// <summary>
  33. /// 获取RevitDll,所在目录
  34. /// </summary>
  35. /// <returns></returns>
  36. public static string GetRevitDllPath()
  37. {
  38. if (!string.IsNullOrWhiteSpace(m_RevitDllPath))
  39. {
  40. return m_RevitDllPath;
  41. }
  42. return Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"..\\RevitDlls");
  43. }
  44. private static string m_RevitDllPath;
  45. public static void SetRevitkDllPath(string path)
  46. {
  47. m_RevitDllPath = path;
  48. }
  49. #endregion
  50. }
  51. }