ParseEquipment.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. using Autodesk.Revit.DB;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using SAGA.RevitUtils.Extends;
  8. using SAGA.MBI.Tools;
  9. using System.Text.RegularExpressions;
  10. using SAGA.MBI.RevitExport.Entity;
  11. using XYZ = Autodesk.Revit.DB.XYZ;
  12. namespace SAGA.MBI.RevitExport.ParseElement
  13. {
  14. [LoadParse]
  15. public class ParseEquipment : IParseRevitElement
  16. {
  17. public bool Match(RevitElementWrapper wrapper)
  18. {
  19. return wrapper.Category == MbiElementCategory.Equipment;
  20. }
  21. public void Parse(RevitElementWrapper wrapper, ExportDb db)
  22. {
  23. try
  24. {
  25. FamilyInstance equipment = wrapper.RefElement as FamilyInstance;
  26. if (equipment == null)
  27. return;
  28. var family = equipment.GetFamily();
  29. var name = family.Name;
  30. if (!equipment.IsMbiEquipment())
  31. {
  32. return;
  33. }
  34. MbiEquipment jObject = new MbiEquipment();
  35. ParseCore.AttachObject(jObject, equipment);
  36. do
  37. {
  38. //Location
  39. jObject.Location = GeometryLocation.CreatePointLocation(BimConvert.ConvertToXYZ(equipment.GetLocationPoint()));
  40. //OutLine
  41. var polygonPath = RevitUtil.GetBottomPolygon(equipment);
  42. if (polygonPath != null && polygonPath.Any())
  43. {
  44. Polygon outLine = new Polygon(BimConvert.ConvertToXYZs(polygonPath));
  45. jObject.OutLine.Add(outLine);
  46. }
  47. //FamilyName
  48. jObject.FamilyName = equipment.GetFamilyName();
  49. //Tag
  50. jObject.Tag = "";
  51. //Id
  52. } while (false);
  53. db.AddEquipment(jObject);
  54. }
  55. catch (Exception e)
  56. {
  57. }
  58. }
  59. }
  60. }