ParseWindow.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*-------------------------------------------------------------------------
  2. * 功能描述:ParseWindow
  3. * 作者:xulisong
  4. * 创建时间: 2019/6/25 17:52:58
  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. namespace RevitToJBim.ComponentParse
  20. {
  21. [UsableParse]
  22. public class ParseWindow : ParseBase
  23. {
  24. public override List<string> FastIndex()
  25. {
  26. return new List<string>() { CategoryGenerator.BuildingCategory(JFamilyType.Window) };
  27. }
  28. public override bool Match(ElementWrapper wrapper)
  29. {
  30. return wrapper.Category == CategoryGenerator.BuildingCategory(JFamilyType.Window);
  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. Window jObject = new Window();
  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. return new List<BimId>() { jObject.Id };
  54. }
  55. }
  56. }