RevitModelPath.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using SAGA.MBI.DataArrange;
  7. using SAGA.MBI.Model;
  8. using SAGA.Models;
  9. namespace SAGA.GplotRelationComputerManage
  10. {
  11. public class RevitModelPath
  12. {
  13. private static List<string> FilePaths = new List<string>();
  14. /// <summary>
  15. /// 获取所有Revit文件信息(目录结构:根目录+proId+proName+builtingName)
  16. /// </summary>
  17. /// <returns></returns>
  18. public static List<string> GetAllRevitFiles()
  19. {
  20. var changeIds = DrawDataServer.GetData<List<string>>("ChangeFloorIds");
  21. if (changeIds.Count > 0)
  22. {
  23. DrawDataServer.ClearData<List<string>>("ChangeFloorIds");
  24. return changeIds;
  25. }
  26. if (FilePaths.Count == 0)
  27. {//TODO:有测试
  28. List<string> files = new List<string>();
  29. var projectFloors = DalModeFileManange.GetMissFileFloors(false);//.Where(t => t.Item.LocalName == "大师傅地方").ToList();
  30. projectFloors.ForEach((tni) => GetFilePaths(tni, files));
  31. files.Reverse();
  32. FilePaths = new List<string>(files);
  33. }
  34. return FilePaths;
  35. }
  36. /// <summary>
  37. /// 获取所有楼层信息
  38. /// </summary>
  39. /// <param name="tni"></param>
  40. /// <param name="files"></param>
  41. private static void GetFilePaths(TreeNodeItem tni, List<string> files)
  42. {
  43. if (tni.Item is MFloor floor)
  44. {
  45. files.Add(floor.FullPath);
  46. }
  47. else
  48. {
  49. foreach (TreeNodeItem t in tni.Children)
  50. {
  51. GetFilePaths(t, files);
  52. }
  53. }
  54. }
  55. }
  56. }