ParseDoor.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*-------------------------------------------------------------------------
  2. * 功能描述:ParseDoor
  3. * 作者:xulisong
  4. * 创建时间: 2019/6/25 17:53:11
  5. * 版本号:v1.0
  6. * -------------------------------------------------------------------------*/
  7. using RevitExport.Export;
  8. using RevitToJBim.Common;
  9. using System;
  10. using System.Collections.Generic;
  11. using System.Linq;
  12. using System.Text;
  13. using System.Threading.Tasks;
  14. using JFamilyType = RevitToJBim.Common.FamilyType;
  15. using JBIM;
  16. using Autodesk.Revit.DB;
  17. using JBIM.Component;
  18. using JBIM.Definition;
  19. namespace RevitToJBim.ComponentParse
  20. {
  21. [UsableParse]
  22. public class ParseDoor : ParseBase
  23. {
  24. public override List<string> FastIndex()
  25. {
  26. return new List<string>() { CategoryGenerator.BuildingCategory(JFamilyType.Door) };
  27. }
  28. public override bool Match(ElementWrapper wrapper)
  29. {
  30. return wrapper.Category == CategoryGenerator.BuildingCategory(JFamilyType.Door);
  31. }
  32. protected override List<BimId> ParseInner(ElementWrapper wrapper, JBimParseContext context)
  33. {
  34. if (!(wrapper.RefElement is FamilyInstance fi))
  35. {
  36. return null;
  37. }
  38. Door jObject = new Door();
  39. ParseCore.AttachObject(jObject, wrapper);
  40. context.AddBimObject(jObject);
  41. jObject.Location = ParseCore.GetLocation(fi.Location);
  42. if (fi.Host != null)
  43. {
  44. jObject.Owner = context.Parser.ParseElement(ElementWrapperFactory.CreateWrapper(fi.Host))?.FirstOrDefault();
  45. jObject.Thick = (fi.Host as Autodesk.Revit.DB.Wall).Width.FtToUse();
  46. }
  47. var polygonPath = RevitUtil.GetWindowDoorLocation(fi);
  48. if (polygonPath != null && polygonPath.Any())
  49. {
  50. Polygon outLine = new Polygon(BimConvert.ConvertToXYZs(polygonPath,true));
  51. jObject.OutLine.Add(outLine);
  52. }
  53. jObject.HandDirection = BimConvert.ConvertToDirection(fi.HandOrientation);
  54. jObject.FaceDirection = BimConvert.ConvertToDirection(fi.FacingOrientation);
  55. return new List<BimId>() { jObject.Id };
  56. }
  57. }
  58. }