Command.cs 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. using DrawData;
  2. using System;
  3. using System.Linq;
  4. using Autodesk.Revit.Attributes;
  5. using Autodesk.Revit.DB;
  6. using Autodesk.Revit.UI;
  7. using SAGA.GplotDrawData;
  8. using SAGA.GplotRelationComputerManage.PumpEnd;
  9. using SAGA.RevitUtils;
  10. using SAGA.RevitUtils.Extends;
  11. using MainWindow = SAGA.GplotDrawData.MainWindow;
  12. namespace SAGA.GplotRelationComputerManage
  13. {
  14. /// <summary>
  15. /// 供水管 回水管拓扑图
  16. /// </summary>
  17. [Transaction(TransactionMode.Manual)]
  18. [Regeneration(RegenerationOption.Manual)]
  19. public class SupplyHydronicTopoGraph : ExternalCommand
  20. {
  21. public override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
  22. {
  23. base.Execute(commandData, ref message, elements);
  24. using (Transaction trans = new Transaction(ExternalDataWrapper.Current.Doc, "读取风管系统"))
  25. {
  26. trans.Start();
  27. try
  28. {
  29. DuctTerminalBll.DrawPipePlane();
  30. trans.Commit();
  31. }
  32. catch (Exception e)
  33. {
  34. trans.RollBack();
  35. MessageShow.Show(e);
  36. }
  37. }
  38. return Result.Succeeded;
  39. }
  40. }
  41. /// <summary>
  42. /// 配电关系图--配电柜与配电柜
  43. /// </summary>
  44. [Transaction(TransactionMode.Manual)]
  45. [Regeneration(RegenerationOption.Manual)]
  46. public class DistributionRelationshipCommand : ExternalCommand
  47. {
  48. public override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
  49. {
  50. #region 核心
  51. try
  52. {
  53. DistributionRelationshipHandler handler = new DistributionRelationshipHandler();
  54. var re = handler.GetViewData(new PowerComputerContext());
  55. if (re[0].Childrens.Any())
  56. {
  57. WinEquipmentRelation_Web window =
  58. new WinEquipmentRelation_Web(re[0].Childrens, re[1].Childrens);
  59. window.Title = "配电拓扑图:配电柜--配电柜";
  60. window.Show();
  61. }
  62. }
  63. catch (Exception ex)
  64. {
  65. MessageShow.Show(ex);
  66. }
  67. #endregion
  68. return Result.Succeeded;
  69. }
  70. public override bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories)
  71. {
  72. return true;
  73. }
  74. }
  75. /// <summary>
  76. /// 配电关系图--配电柜与配电设备
  77. /// </summary>
  78. [Transaction(TransactionMode.Manual)]
  79. [Regeneration(RegenerationOption.Manual)]
  80. public class DistributionEqRelationshipCommand : ExternalCommand
  81. {
  82. public override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
  83. {
  84. #region 核心处理
  85. EquipPowerRelationshipHandler handler = new EquipPowerRelationshipHandler();
  86. var re = handler.GetViewData(new PowerComputerContext());
  87. if (re[0].Childrens.Any())
  88. {
  89. WinEquipmentRelation_Web window =
  90. new WinEquipmentRelation_Web(re[0].Childrens, re[1].Childrens);
  91. window.Title = "配电拓扑图:配电柜--末端";
  92. window.Show();
  93. }
  94. #endregion
  95. return Result.Succeeded;
  96. }
  97. public override bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories)
  98. {
  99. return true;
  100. }
  101. }
  102. /// <summary>
  103. /// 对象受控关系
  104. /// </summary>
  105. [Transaction(TransactionMode.Manual)]
  106. [Regeneration(RegenerationOption.Manual)]
  107. public class BelongEqRelationshipCommand : ExternalCommand
  108. {
  109. public override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
  110. {
  111. #region 核心处理
  112. ObjectControlRelationshipHandler handler = new ObjectControlRelationshipHandler();
  113. var re = handler.GetViewData(new PowerComputerContext());
  114. if (re[0].Childrens.Any())
  115. {
  116. WinControlRelation_Web window =
  117. new WinControlRelation_Web(re[0].Childrens, re[1].Childrens);
  118. window.Title = "对象受控关系图";
  119. window.Show();
  120. }
  121. #endregion
  122. return Result.Succeeded;
  123. }
  124. public override bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories)
  125. {
  126. return true;
  127. }
  128. }
  129. /// <summary>
  130. /// 空间关系查看
  131. /// </summary>
  132. [Transaction(TransactionMode.Manual)]
  133. [Regeneration(RegenerationOption.Manual)]
  134. public class SpaceViewCommand : ExternalCommand
  135. {
  136. public SpaceViewCommand()
  137. {
  138. IsShowNoDocument = true;
  139. }
  140. public override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
  141. {
  142. try
  143. {
  144. var win = new WinDrawSpace();
  145. win.ShowDialog();
  146. }
  147. catch (Exception e)
  148. {
  149. MessageShow.Show(e);
  150. }
  151. return Result.Succeeded;
  152. }
  153. }
  154. }