RevitUtils.cs 1.8 KB

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