ParseWindow.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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 RevitToJBim.Extension;
  19. using JFamilyType = RevitToJBim.Common.FamilyType;
  20. namespace RevitToJBim.ComponentParse
  21. {
  22. [UsableParse]
  23. public class ParseWindow : ParseBase
  24. {
  25. public override List<string> FastIndex()
  26. {
  27. return new List<string>() { CategoryGenerator.BuildingCategory(JFamilyType.Window) };
  28. }
  29. public override bool Match(ElementWrapper wrapper)
  30. {
  31. return wrapper.Category == CategoryGenerator.BuildingCategory(JFamilyType.Window);
  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. Window jObject = new Window();
  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. return new List<BimId>() { jObject.Id };
  58. }
  59. }
  60. }