ParseGrid.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /* ==============================================================================
  2. * 功能描述:ParseGrid
  3. * 创 建 者:Garrett
  4. * 创建日期:2019/6/26 15:16:06
  5. * ==============================================================================*/
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using Autodesk.Revit.DB;
  12. using JBIM;
  13. using JBIM.Definition;
  14. using RevitExport.Export;
  15. using RevitToJBim.Common;
  16. using SAGA.RevitUtils.Extends;
  17. using JGrid=JBIM.Component.Grid;
  18. namespace RevitToJBim.ComponentParse
  19. {
  20. /// <summary>
  21. /// ParseGrid
  22. /// </summary>
  23. [UsableParseAttribute]
  24. class ParseGrid : ParseBase
  25. {
  26. public override List<string> FastIndex()
  27. {
  28. return new List<string>(){typeof(Grid).FullName};
  29. }
  30. public override bool Match(ElementWrapper wrapper)
  31. {
  32. return wrapper.RefElement is Grid;
  33. }
  34. protected override List<BimId> ParseInner(ElementWrapper wrapper, JBimParseContext context)
  35. {
  36. var refElement = wrapper.RefElement as Grid;
  37. if (refElement == null)
  38. {
  39. return null;
  40. }
  41. JGrid jObject = new JGrid();
  42. //ElementType
  43. ParseCore.AttachObject(jObject, wrapper);
  44. //Name,SourceId
  45. jObject.Name = refElement.Name;
  46. //Location
  47. var locations = refElement.GetCurve().Tessellate();
  48. jObject.Location = GeometryLocation.CreateLineLocation(BimConvert.ConvertToXYZs(locations.ToList()));
  49. //Id
  50. context.AddBimObject(jObject);
  51. return new List<BimId>() { jObject.Id };
  52. }
  53. }
  54. }