ComputerPipes.cs 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /* ==============================================================================
  2. * 功能描述:计算管道关系
  3. * 创 建 者:SAGACLOUD
  4. * 创建日期:2017/9/1 16:56:23
  5. * ==============================================================================*/
  6. using System;
  7. using SAGA.GplotRelationComputerManage.PumpEnd;
  8. using SAGA.RevitUtils.Extends;
  9. using System.Collections.Generic;
  10. using System.IO;
  11. using System.Linq;
  12. using Autodesk.Revit.DB.Plumbing;
  13. using Autodesk.Revit.DB;
  14. using SAGA.MBI.Tools;
  15. using SAGA.RevitUtils;
  16. namespace SAGA.GplotRelationComputerManage
  17. {
  18. public class ComputerPipes
  19. {
  20. public static void Computer()
  21. {
  22. //打开所有楼层数据
  23. PipeCalcContext context = new PipeCalcContext();
  24. var fileInfos = RevitModelPath.GetAllRevitFiles();
  25. foreach (var fileInfo in fileInfos)
  26. {
  27. if (File.Exists(fileInfo))
  28. {
  29. var uiApp = ExternalDataWrapper.Current.UiApp.Application;
  30. var doc = uiApp.OpenDocumentFile(fileInfo);
  31. if (doc == null)
  32. continue;
  33. try
  34. {
  35. new ExternalDataWrapper(doc);
  36. List<Pipe> verticalPipes = new List<Pipe>();
  37. //计算水管
  38. DuctTerminalBll.DrawPipePlane(false, verticalPipes);
  39. #region 立管处理
  40. ComputerVerticalPipe computerPipes = new ComputerVerticalPipe(doc);
  41. //立管处理,分楼层存储
  42. var usePlan = doc.GetViewPlan().Where(p => p.Name.Contains("-saga"))?.FirstOrDefault();
  43. var currentLevel = usePlan?.GenLevel;
  44. if (usePlan == null)
  45. {
  46. currentLevel = verticalPipes.FirstOrDefault()?.ReferenceLevel;
  47. }
  48. //楼层必须要有,管道不一定要有
  49. if (currentLevel != null)
  50. {
  51. computerPipes.ComputerVerticalPipes(currentLevel, verticalPipes, context);
  52. }
  53. #endregion
  54. //计算风管
  55. DuctTerminalBll.DrawDuct();
  56. }
  57. catch (System.Exception ex)
  58. {
  59. Console.WriteLine(ex.Message);
  60. }
  61. finally
  62. {
  63. doc.CloseDocSimple();
  64. }
  65. }
  66. }
  67. ComputerVerticalPipe.Computer(context);
  68. }
  69. }
  70. }