ComputerPipes.cs 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /* ==============================================================================
  2. * 功能描述:计算管道关系
  3. * 创 建 者:SAGACLOUD
  4. * 创建日期:2017/9/1 16:56:23
  5. * ==============================================================================*/
  6. using SAGA.GplotRelationComputerManage.PumpEnd;
  7. using SAGA.RevitUtils.Extends;
  8. using System.Collections.Generic;
  9. using System.IO;
  10. using System.Linq;
  11. using System.Text.RegularExpressions;
  12. using Autodesk.Revit.DB.Plumbing;
  13. using Autodesk.Revit.DB;
  14. namespace SAGA.GplotRelationComputerManage
  15. {
  16. public class ComputerPipes
  17. {
  18. public static void Computer()
  19. {
  20. //记录立管
  21. //List<Pipe> verticalPipe = new List<Pipe>();
  22. Dictionary<Level, List<Pipe>> dicVerticalPipes = new Dictionary<Level, List<Pipe>>();
  23. //打开所有楼层数据
  24. // var fileInfos = RevitModelPath.GetAllRevitFiles();//.Where(t=>Regex.IsMatch(t, "Fl1101080003e883286bb63d11e8b92a092227bd993a"));//B2
  25. var fileInfos = RevitModelPath.GetAllRevitFiles();//.Where(t=>Regex.IsMatch(t, "ee2c4"));//Test
  26. foreach (var fileInfo in fileInfos)
  27. {
  28. if (File.Exists(fileInfo))
  29. {
  30. var uiApp = ExternalDataWrapper.Current.UiApp.Application;
  31. var doc = uiApp.OpenDocumentFile(fileInfo);
  32. new ExternalDataWrapper(doc);
  33. List<Pipe> verticalPipe = new List<Pipe>();
  34. //计算水管
  35. DuctTerminalBll.DrawPipePlane(false, verticalPipe);
  36. #region 立管处理
  37. //立管处理,分楼层存储
  38. var usePlan = doc.GetViewPlan().Where(p => p.Name.Contains("-saga"))?.FirstOrDefault();
  39. var currentLevel = usePlan?.GenLevel;
  40. if (usePlan == null)
  41. {
  42. currentLevel = verticalPipe.FirstOrDefault()?.ReferenceLevel;
  43. }
  44. //楼层必须要有,管道不一定要有
  45. if (currentLevel != null)
  46. {
  47. dicVerticalPipes.Add(currentLevel, verticalPipe);
  48. }
  49. #endregion
  50. //计算风管
  51. DuctTerminalBll.DrawDuct();
  52. }
  53. }
  54. //计算立管
  55. //if(ExternalDataWrapper.Current?.Doc==null)return;
  56. //var levels =ExternalDataWrapper.Current.Doc.GetLevels();
  57. var pipeComputer = new ComputerVerticalPipe();
  58. pipeComputer.Computer(dicVerticalPipes);
  59. }
  60. }
  61. }