ParseMepSystem.cs 2.6 KB

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