ParseFamilyJoinObject.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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.RevitUtils.Extends;
  22. using SAGA.RevitUtils.MEP;
  23. namespace RevitToJBim.ComponentParse
  24. {
  25. [UsableParse]
  26. public class ParseFamilyJoinObject : ParseBase
  27. {
  28. public override List<string> FastIndex()
  29. {
  30. return new List<string>() { CategoryGenerator .BuildingCategory(JFamilyType.JoinObject)};
  31. }
  32. public override bool Match(ElementWrapper wrapper)
  33. {
  34. return wrapper.Category == CategoryGenerator.BuildingCategory(JFamilyType.JoinObject);
  35. }
  36. protected override List<BimId> ParseInner(ElementWrapper wrapper, JBimParseContext context)
  37. {
  38. if (!(wrapper.RefElement is FamilyInstance familyInstance))
  39. {
  40. return null;
  41. }
  42. //ElementType
  43. OtherJoinObject jObject = new OtherJoinObject();
  44. //Name,SourceId
  45. ParseCore.AttachObject(jObject, wrapper);
  46. //FamilyName
  47. jObject.FamilyName = familyInstance.GetFamilyName();
  48. jObject.FamilySymbol = familyInstance.GetFamilySymbolName();
  49. //Location
  50. jObject.Location = GeometryLocation.CreatePointLocation(BimConvert.ConvertToXYZ(familyInstance.GetLocationPoint()));
  51. //OutLine
  52. var polygonPath = RevitUtil.GetBottomPolygon(familyInstance);
  53. if (polygonPath != null && polygonPath.Any())
  54. {
  55. Polygon outLine = new Polygon(BimConvert.ConvertToXYZs(polygonPath));
  56. jObject.OutLine.Add(outLine);
  57. }
  58. //Id
  59. context.AddBimObject(jObject);
  60. #region Connector连接关系
  61. var connectors = familyInstance.GetAllConnectors();
  62. if (connectors.Any())
  63. {
  64. ElementOneToManyRel relMany = ParseCore.GetConnectorRels(familyInstance,connectors);
  65. context.RelationShips.Add(relMany);
  66. }
  67. #endregion
  68. return new List<BimId>() { jObject.Id };
  69. }
  70. public override List<ElementWrapper> ArrangeRefElements(ElementWrapper wrapper, JBimParseContext context)
  71. {
  72. if (!(wrapper.RefElement is FamilyInstance fi))
  73. {
  74. return null;
  75. }
  76. var wrappers = new List<ElementWrapper>() { };
  77. var connectors = fi.GetAllConnectors();
  78. foreach (var connector in connectors)
  79. {
  80. wrappers.Add(ParseCore.GetConnectorWrapper(connector));
  81. }
  82. return wrappers;
  83. }
  84. }
  85. }