ParseFamilyJoinObject.cs 2.9 KB

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