OtherCommand.cs 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /* ==============================================================================
  2. * 功能描述:OtherCommand
  3. * 创 建 者:Garrett
  4. * 创建日期:2019/11/26 9:49:59
  5. * ==============================================================================*/
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using System.Windows.Forms;
  12. using Autodesk.Revit.Attributes;
  13. using Autodesk.Revit.DB;
  14. using Autodesk.Revit.UI;
  15. using FWindSoft.Data;
  16. using FWindSoft.Revit;
  17. using FWindSoft.Revit.Menu;
  18. using Saga.PlugIn.ModelCheck;
  19. using Saga.PlugIn.Other;
  20. using SAGA.DotNetUtils.Geometry;
  21. using SAGA.DotNetUtils.Others;
  22. using SAGA.RevitUtils;
  23. using SAGA.RevitUtils.Extends;
  24. using ExternalCommand = FWindSoft.Revit.ExternalCommand;
  25. namespace LRH.Tool
  26. {
  27. /// <summary>
  28. /// 查询设备所在空间
  29. /// </summary>
  30. [Transaction(TransactionMode.Manual)]
  31. [Regeneration(RegenerationOption.Manual)]
  32. [Button(ButtonName = "查询设备所在空间", Index = 1, TabName = "禹数建模工具", PanelName = "工具", ImageName = "pack://application:,,,/Saga.PlugIn;component/Image/查询设备所在空间")]
  33. public class ReportEquipInSpaceCommand : ExternalCommand
  34. {
  35. public override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
  36. {
  37. try
  38. {
  39. var fi = commandData.Application.PickElement("请选择图元") as FamilyInstance;
  40. if (fi == null) return Result.Succeeded;
  41. var space = fi.GetReferenceSpace();
  42. string str = "", str2 = "";
  43. do
  44. {
  45. if (space != null)
  46. {
  47. List<XYZ> spaceVertex = space.GetBoundaryVertexes().FirstOrDefault();
  48. if (spaceVertex == null)
  49. {
  50. str = "Boundary 为Null";
  51. break;
  52. }
  53. }
  54. } while (false);
  55. MessageShowBase.Infomation($"设备所在空间Id为{space?.Id}");
  56. }
  57. catch (Exception e)
  58. {
  59. MessageShow.Show(e);
  60. return Result.Cancelled;
  61. }
  62. return Result.Succeeded;
  63. }
  64. }
  65. /// <summary>
  66. /// 复制指定参数A的值到指定参数B中
  67. /// </summary>
  68. [Transaction(TransactionMode.Manual)]
  69. [Regeneration(RegenerationOption.Manual)]
  70. [Button(ButtonName = "复制指定参数A的值到指定参数B中", Index = 2, TabName = "禹数建模工具", PanelName = "工具", ImageName = "pack://application:,,,/Saga.PlugIn;component/Image/复制指定参数A的值到指定参数B中")]
  71. public class CopyParameterValueCommand : ExternalCommand
  72. {
  73. public override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
  74. {
  75. try
  76. {
  77. var tip = MessageShowBase.Question("确定要复制参数?");
  78. if (tip)
  79. {
  80. WinParameterDic win = new WinParameterDic();
  81. if (win.ShowDialog() == true)
  82. {
  83. if (!SingleInstance<CopyParameterValue>.Instance.SetCopyParameterDic(win.ParameterDic,
  84. win.CopyRange)) return Result.Cancelled;
  85. var doc = RevitCore.Doc;
  86. SingleInstance<CopyParameterValue>.Instance.Execute(doc);
  87. MessageShowBase.Infomation("信息点的值复制完成");
  88. }
  89. }
  90. }
  91. catch (Exception e)
  92. {
  93. MessageShow.Show(e);
  94. return Result.Cancelled;
  95. }
  96. return Result.Succeeded;
  97. }
  98. public override bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories)
  99. {
  100. return true;
  101. }
  102. }
  103. /// <summary>
  104. /// 重命名系统名称
  105. /// </summary>
  106. [Transaction(TransactionMode.Manual)]
  107. [Regeneration(RegenerationOption.Manual)]
  108. [Button(ButtonName = "重命名系统名称", Index = 3, TabName = "禹数建模工具", PanelName = "工具", ImageName = "pack://application:,,,/Saga.PlugIn;component/Image/重命名系统名称")]
  109. public class RenameSystemNameCommand : ExternalCommand
  110. {
  111. public override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
  112. {
  113. try
  114. {
  115. var iDataCorrect = new RenameSystemName();
  116. if (true)
  117. {
  118. WinRenameConfig win = new WinRenameConfig();
  119. if (win.ShowDialog() == true)
  120. {
  121. iDataCorrect.Operate(win.ReferenceFilePath, win.RevitDirs);
  122. MessageShowBase.Infomation("系统名称已修改,请检查");
  123. }
  124. }
  125. }
  126. catch (Exception e)
  127. {
  128. MessageShow.Show(e);
  129. return Result.Cancelled;
  130. }
  131. return Result.Succeeded;
  132. }
  133. public override bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories)
  134. {
  135. return true;
  136. }
  137. }
  138. }