ParseJoinObject.cs 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*-------------------------------------------------------------------------
  2. * 功能描述:ParseFamilyJoinObject
  3. * 作者:xulisong
  4. * 创建时间: 2019/6/24 9:29:00
  5. * 版本号:v1.0
  6. * -------------------------------------------------------------------------*/
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12. using Autodesk.Revit.DB;
  13. using JBIM;
  14. using JBIM.Component;
  15. using JBIM.Definition;
  16. using RevitExport.Export;
  17. using RevitToJBim.Common;
  18. using RevitToJBim.Extension;
  19. using JFamilyType=RevitToJBim.Common.FamilyType;
  20. using RevitToJBim.ParseData;
  21. using SAGA.DotNetUtils.Extend;
  22. using SAGA.RevitUtils.Extends;
  23. using SAGA.RevitUtils.MEP;
  24. namespace RevitToJBim.ComponentParse
  25. {
  26. [UsableParse]
  27. public class ParseJoinObject : ParseBase
  28. {
  29. public override List<string> FastIndex()
  30. {
  31. return new List<string>() { CategoryGenerator .BuildingCategory(JFamilyType.JoinObject)};
  32. }
  33. public override bool Match(ElementWrapper wrapper)
  34. {
  35. return wrapper.Category == CategoryGenerator.BuildingCategory(JFamilyType.JoinObject);
  36. }
  37. protected override List<BimId> ParseInner(ElementWrapper wrapper, JBimParseContext context)
  38. {
  39. if (!(wrapper.RefElement is FamilyInstance familyInstance))
  40. {
  41. return null;
  42. }
  43. //ElementType
  44. OtherJoinObject jObject = new OtherJoinObject();
  45. //Name,SourceId
  46. ParseCore.AttachObject(jObject, wrapper);
  47. //FamilyName
  48. jObject.FamilyName = familyInstance.GetFamilyName();
  49. jObject.FamilySymbol = familyInstance.GetFamilySymbolName();
  50. //Location
  51. jObject.Location = GeometryLocation.CreatePointLocation(BimConvert.ConvertToXYZ(familyInstance.GetLocationPoint()));
  52. jObject.Rotation = familyInstance.GetRotation().ToAngle();
  53. //OutLine
  54. var polygonPath = RevitUtil.GetBottomPolygon(familyInstance);
  55. if (polygonPath != null && polygonPath.Any())
  56. {
  57. Polygon outLine = new Polygon(BimConvert.ConvertToXYZs(polygonPath));
  58. jObject.OutLine.Add(outLine);
  59. }
  60. //Id
  61. context.AddBimObject(jObject);
  62. #region Connector连接关系
  63. var connectors = familyInstance.GetAllConnectors();
  64. if (connectors.Any())
  65. {
  66. ElementOneToManyRel relMany = ParseCore.GetConnectorRels(familyInstance,connectors);
  67. context.RelationShips.Add(relMany);
  68. }
  69. #endregion
  70. return new List<BimId>() { jObject.Id };
  71. }
  72. public override List<ElementWrapper> ArrangeRefElements(ElementWrapper wrapper, JBimParseContext context)
  73. {
  74. if (!(wrapper.RefElement is FamilyInstance fi))
  75. {
  76. return null;
  77. }
  78. var wrappers = new List<ElementWrapper>() { };
  79. var connectors = fi.GetAllConnectors();
  80. foreach (var connector in connectors)
  81. {
  82. wrappers.Add(ParseCore.GetConnectorWrapper(connector));
  83. }
  84. return wrappers;
  85. }
  86. }
  87. }