JoinCreator.cs 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. 
  2. using Autodesk.Revit.DB;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.IO;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. namespace FWindSoft.Revit.Mep
  10. {
  11. ///// <summary>
  12. ///// 连接生成器
  13. ///// </summary>
  14. //public class JoinCreator
  15. //{
  16. // public JoinCreator(IMepCurveJoin curveJoin, IMepEquipmentJoin equipmentJoin)
  17. // {
  18. // CurveJoin = curveJoin;
  19. // EequipmentJoin = equipmentJoin;
  20. // }
  21. // /// <summary>
  22. // /// 管线连接
  23. // /// </summary>
  24. // public IMepCurveJoin CurveJoin { get; private set; }
  25. // /// <summary>
  26. // /// 末端连接
  27. // /// </summary>
  28. // public IMepEquipmentJoin EequipmentJoin { get; private set; }
  29. // /// <summary>
  30. // /// 创建连接
  31. // /// </summary>
  32. // /// <param name="cre"></param>
  33. // /// <param name="idDict"></param>
  34. // /// <param name="doc"></param>
  35. // public virtual bool CreateConnectors(ConnectorRvtElement cre, Dictionary<string, string> idDict,Document doc)
  36. // {
  37. // /*
  38. // * 记录未成功连接的数据
  39. // */
  40. // bool? result = false;
  41. // var joinElements = cre.conduit_list;
  42. // var joinElementRevitIds = joinElements.Select(global =>
  43. // { idDict.TryGetValue(global, out string revitId);
  44. // return revitId;
  45. // }).OfType<string>();
  46. // var revitELements = joinElementRevitIds.Select(id => doc.GetElement(new ElementId(id.ToInt()))).ToList();
  47. // JoinContext context = new JoinContext();//预留,附加信息可能会在这个类中进行扩展
  48. // var elementWrappers = revitELements.Select(el => new JoinElementWraper(el)).ToList();//使用Wrapper代理,为了方便扩展一些自定义扩展数据
  49. // try
  50. // {
  51. // switch (elementWrappers.Count())
  52. // {
  53. // case 2:
  54. // {
  55. // if (elementWrappers.Any(ew => ew.IsFamilyInstance))
  56. // {
  57. // result = EequipmentJoin?.JoinEquipment(elementWrappers, context);
  58. // }
  59. // else
  60. // {
  61. // result = CurveJoin?.Join2Curve(elementWrappers, context);
  62. // }
  63. // break;
  64. // }
  65. // case 3:
  66. // {
  67. // result = CurveJoin?.Join3Curve(elementWrappers, context);
  68. // break;
  69. // }
  70. // case 4:
  71. // {
  72. // result = CurveJoin?.Join4Curve(elementWrappers, context);
  73. // break;
  74. // }
  75. // }
  76. // }
  77. // catch (Exception ex)
  78. // {
  79. // //自动执行,暂时不抛出异常,
  80. // result = false;
  81. // //throw;
  82. // }
  83. // if(result != true)
  84. // {
  85. // List<string> ids = elementWrappers.Select(ew => ew.AssociateElement?.Id.ToString()).ToList();
  86. // var filePath = Path.Combine(AppBaseInfo.LogPath, "测试.txt");
  87. // if(!Directory.GetParent(filePath).Exists)
  88. // {
  89. // Directory.GetParent(filePath).Create();
  90. // }
  91. // File.AppendAllLines(filePath, new List<string>() {DateTime.Now.ToString("yyyyMMddHHmmss :") + string.Join(",", ids) });
  92. // }
  93. // return result == true;
  94. // }
  95. // #region 单例连接生成器
  96. // private static JoinCreator m_ConduitJoinCreator;
  97. // /// <summary>
  98. // /// 线管连接器
  99. // /// </summary>
  100. // /// <returns></returns>
  101. // public static JoinCreator ConduitJoinCreator
  102. // {
  103. // get
  104. // {
  105. // if(m_ConduitJoinCreator == null)
  106. // {
  107. // m_ConduitJoinCreator= new JoinCreator(new ConduitJoin(), null);
  108. // }
  109. // return m_ConduitJoinCreator;
  110. // }
  111. // }
  112. // private static JoinCreator m_PipeJoinCreator;
  113. // /// <summary>
  114. // /// 水管连接器
  115. // /// </summary>
  116. // /// <returns></returns>
  117. // public static JoinCreator PipeJoinCreator
  118. // {
  119. // get
  120. // {
  121. // if (m_PipeJoinCreator == null)
  122. // {
  123. // m_PipeJoinCreator = new JoinCreator(null, null);
  124. // }
  125. // return m_PipeJoinCreator;
  126. // }
  127. // }
  128. // private static JoinCreator m_DuctJoinCreator;
  129. // /// <summary>
  130. // /// 风管连接器
  131. // /// </summary>
  132. // /// <returns></returns>
  133. // public static JoinCreator DuctJoinCreator
  134. // {
  135. // get
  136. // {
  137. // if (m_DuctJoinCreator == null)
  138. // {
  139. // m_DuctJoinCreator = new JoinCreator(null, null);
  140. // }
  141. // return m_DuctJoinCreator;
  142. // }
  143. // }
  144. // private static JoinCreator m_CableTrayJoinCreator;
  145. // /// <summary>
  146. // /// 桥架连接器
  147. // /// </summary>
  148. // /// <returns></returns>
  149. // public static JoinCreator CableTrayJoinCreator
  150. // {
  151. // get
  152. // {
  153. // if (m_CableTrayJoinCreator == null)
  154. // {
  155. // m_CableTrayJoinCreator = new JoinCreator(null, null);
  156. // }
  157. // return m_CableTrayJoinCreator;
  158. // }
  159. // }
  160. // #endregion
  161. //}
  162. }