ParseFamilyJoinObject.cs 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 RevitExport.Export;
  16. using RevitToJBim.Common;
  17. using JFamilyType=RevitToJBim.Common.FamilyType;
  18. using RevitToJBim.ParseData;
  19. using SAGA.RevitUtils.MEP;
  20. namespace RevitToJBim.ComponentParse
  21. {
  22. [UsableParse]
  23. public class ParseFamilyJoinObject : ParseBase
  24. {
  25. public override List<string> FastIndex()
  26. {
  27. return new List<string>() { CategoryGenerator .BuildingCategory(JFamilyType.Other)};
  28. }
  29. public override bool Match(ElementWrapper wrapper)
  30. {
  31. return wrapper.Category == CategoryGenerator.BuildingCategory(JFamilyType.Other);
  32. }
  33. protected override List<BimId> ParseInner(ElementWrapper wrapper, JBimParseContext context)
  34. {
  35. if (!(wrapper.RefElement is FamilyInstance familyInstance))
  36. {
  37. return null;
  38. }
  39. OtherJoinObject jObject = new OtherJoinObject();
  40. ParseCore.AttachObject(jObject, wrapper);
  41. context.AddBimObject(jObject);
  42. #region Connector连接关系
  43. var connectors = GetConnectors(familyInstance);
  44. if (connectors.Any())
  45. {
  46. ElementOneToManyRel relMany = ParseCore.GetConnectorRels(familyInstance,connectors);
  47. context.RelationShips.Add(relMany);
  48. }
  49. #endregion
  50. return new List<BimId>() { jObject.Id };
  51. }
  52. public override List<ElementWrapper> ArrangeRefElements(ElementWrapper wrapper, JBimParseContext context)
  53. {
  54. if (!(wrapper.RefElement is FamilyInstance fi))
  55. {
  56. return null;
  57. }
  58. var wrappers = new List<ElementWrapper>() { };
  59. var connectors = GetConnectors(fi);
  60. foreach (var connector in connectors)
  61. {
  62. wrappers.Add(ParseCore.GetConnectorWrapper(connector));
  63. }
  64. return wrappers;
  65. }
  66. public List<Autodesk.Revit.DB.Connector> GetConnectors(Element familyInstance)
  67. {
  68. return familyInstance.GetAllConnectors();
  69. }
  70. }
  71. }