ParseDoor.cs 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. using RevitToJBim.Extension;
  20. namespace RevitToJBim.ComponentParse
  21. {
  22. [UsableParse]
  23. public class ParseDoor : ParseBase
  24. {
  25. public override List<string> FastIndex()
  26. {
  27. return new List<string>() { CategoryGenerator.BuildingCategory(JFamilyType.Door) };
  28. }
  29. public override bool Match(ElementWrapper wrapper)
  30. {
  31. return wrapper.Category == CategoryGenerator.BuildingCategory(JFamilyType.Door);
  32. }
  33. protected override List<BimId> ParseInner(ElementWrapper wrapper, JBimParseContext context)
  34. {
  35. if (!(wrapper.RefElement is FamilyInstance fi))
  36. {
  37. return null;
  38. }
  39. Door jObject = new Door();
  40. ParseCore.AttachObject(jObject, wrapper);
  41. context.AddBimObject(jObject);
  42. jObject.Location = ParseCore.GetLocation(fi.Location);
  43. //FamilyName
  44. jObject.FamilyName = fi.GetFamilyName();
  45. jObject.FamilySymbol = fi.GetFamilySymbolName();
  46. if (fi.Host != null)
  47. {
  48. jObject.Owner = context.Parser.ParseElement(ElementWrapperFactory.CreateWrapper(fi.Host))?.FirstOrDefault();
  49. jObject.Thick = (fi.Host as Autodesk.Revit.DB.Wall).Width.FtToUse();
  50. }
  51. var polygonPath = RevitUtil.GetWindowDoorLocation(fi);
  52. if (polygonPath != null && polygonPath.Any())
  53. {
  54. Polygon outLine = new Polygon(BimConvert.ConvertToXYZs(polygonPath,true));
  55. jObject.OutLine.Add(outLine);
  56. }
  57. jObject.HandDirection = BimConvert.ConvertToDirection(fi.HandOrientation);
  58. jObject.FaceDirection = BimConvert.ConvertToDirection(fi.FacingOrientation);
  59. return new List<BimId>() { jObject.Id };
  60. }
  61. }
  62. }