LvSpace.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /* ==============================================================================
  2. * 功能描述:空间信息,用于立管计算
  3. * 创 建 者:SAGACLOUD
  4. * 创建日期:2017/9/1 16:56:23
  5. * ==============================================================================*/
  6. using Autodesk.Revit.DB;
  7. using Autodesk.Revit.DB.Mechanical;
  8. using SAGA.RevitUtils.Extends;
  9. using System.Collections.Generic;
  10. using System.Linq;
  11. namespace SAGA.GplotRelationComputerManage
  12. {
  13. /// <summary>
  14. /// 空间立面计算所需实体
  15. /// </summary>
  16. public class LvSpace
  17. {
  18. public Space Space { get; set; }
  19. public List<BoundarySegment> BoundarySegments
  20. {
  21. get
  22. {
  23. var mySegments = Space.GetBoundarySegments(new SpatialElementBoundaryOptions());
  24. return mySegments.FirstOrDefault()?.ToList();
  25. }
  26. }
  27. private List<Curve> m_curves;
  28. public List<Curve> Curves
  29. {
  30. get
  31. { return m_curves ?? (m_curves = BoundarySegments?.Select(t => t.GetCurve()).ToList()); }
  32. }
  33. public LvSpace(Space space)
  34. {
  35. this.Space = space;
  36. }
  37. /// <summary>
  38. /// 是否被被匹配
  39. /// </summary>
  40. public bool IsPaired { get; set; }
  41. /// <summary>
  42. /// 投影到0平面的轮廓线
  43. /// </summary>
  44. public List<Curve> ZeroCurves
  45. {
  46. get
  47. {
  48. var zeroCurves = new List<Curve>();
  49. if (Curves != null)
  50. {
  51. var z = this.Curves.FirstOrDefault()?.StartPoint()?.Z;
  52. Transform tf = Transform.CreateTranslation(XYZ.Zero.NewZ(0 - z));
  53. foreach (var curve in Curves)
  54. {
  55. zeroCurves.Add(curve.CreateTransformed(tf));
  56. }
  57. }
  58. return zeroCurves;
  59. }
  60. }
  61. public string LevelName { get; set; }
  62. public List<LvSpace> UpLvSpaces { get; set; } = new List<LvSpace>();
  63. }
  64. }