ParseMepSystem.cs 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*-------------------------------------------------------------------------
  2. * 功能描述:ParseMepSystem
  3. * 作者:xulisong
  4. * 创建时间: 2019/6/18 9:16:15
  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 Autodesk.Revit.DB.Mechanical;
  14. using Autodesk.Revit.DB.Plumbing;
  15. using JBIM;
  16. using RevitExport;
  17. using RevitExport.Export;
  18. using JMepSystem = JBIM.Component.MepSystem;
  19. using JMepSystemType = JBIM.Component.MepSystemType;
  20. namespace RevitToJBim.ComponentParse
  21. {
  22. //[UsableParse]
  23. public class ParseMepSystem : ParseBase
  24. {
  25. public override List<string> FastIndex()
  26. {
  27. return new List<string>(){typeof(PipingSystem).FullName, typeof(MechanicalSystem).FullName };
  28. }
  29. public override bool Match(ElementWrapper wrapper)
  30. {
  31. return wrapper.RefElement is MEPSystem;
  32. }
  33. protected override List<BimId> ParseInner(ElementWrapper wrapper, JBimParseContext context)
  34. {
  35. JMepSystem jBimObject = new JMepSystem();
  36. ParseCore.AttachObject(jBimObject, wrapper);
  37. var document = wrapper.RefElement.Document;
  38. #region 直接自己获取解析信息,不通过架构获取
  39. var mepSystemType = document.GetElement(wrapper.RefElement.GetTypeId()) as MEPSystemType;
  40. if (mepSystemType != null)
  41. {
  42. ElementWrapper systemTypeWrapper = new ElementWrapper(mepSystemType);
  43. jBimObject.TypeId = context.Parser.ParseElement(systemTypeWrapper)?.FirstOrDefault();
  44. }
  45. #endregion
  46. context.AddBimObject(jBimObject);
  47. return new List<BimId>() { jBimObject.Id };
  48. }
  49. }
  50. //[UsableParse]
  51. public class ParseMepSystemType : ParseBase
  52. {
  53. public override List<string> FastIndex()
  54. {
  55. return new List<string>() { typeof(PipingSystemType).FullName, typeof(MechanicalSystemType).FullName };
  56. }
  57. public override bool Match(ElementWrapper wrapper)
  58. {
  59. return wrapper.RefElement is MEPSystemType;
  60. }
  61. protected override List<BimId> ParseInner(ElementWrapper wrapper, JBimParseContext context)
  62. {
  63. JMepSystemType jBimObject = new JMepSystemType();
  64. ParseCore.AttachObject(jBimObject, wrapper);
  65. context.AddBimObject(jBimObject);
  66. return new List<BimId>() { jBimObject.Id };
  67. }
  68. }
  69. }