ParseOther.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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 ParseOther : ParseBase
  28. {
  29. public override List<string> FastIndex()
  30. {
  31. return new List<string>() { CategoryGenerator .BuildingCategory(JFamilyType.Other)};
  32. }
  33. public override bool Match(ElementWrapper wrapper)
  34. {
  35. return wrapper.Category == CategoryGenerator.BuildingCategory(JFamilyType.Other);
  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. Other jObject = new Other();
  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. return new List<BimId>() { jObject.Id };
  63. }
  64. public override List<ElementWrapper> ArrangeRefElements(ElementWrapper wrapper, JBimParseContext context)
  65. {
  66. if (!(wrapper.RefElement is FamilyInstance fi))
  67. {
  68. return null;
  69. }
  70. var wrappers = new List<ElementWrapper>() { };
  71. var connectors = fi.GetAllConnectors();
  72. foreach (var connector in connectors)
  73. {
  74. wrappers.Add(ParseCore.GetConnectorWrapper(connector));
  75. }
  76. return wrappers;
  77. }
  78. }
  79. }