MBIDocument.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*-------------------------------------------------------------------------
  2. * 功能描述:MBIDocument
  3. * 作者:xulisong
  4. * 创建时间: 2019/6/28 10:57:07
  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 Newtonsoft.Json.Linq;
  15. using SAGA.DotNetUtils.Extend;
  16. using SAGA.RevitUtils;
  17. namespace RevitToJBim.MBI
  18. {
  19. /// <summary>
  20. /// 项目传输数据结构
  21. /// </summary>
  22. public class MBIDocument
  23. {
  24. public string MBIName { get; set; }
  25. public string ModelId { get; set; }
  26. public string PlanName { get; set; }
  27. public Dictionary<string, List<BimObject>> Elements { get; private set; }
  28. /// <summary>
  29. /// 附加元素Elements信息
  30. /// </summary>
  31. /// <param name="document"></param>
  32. public void AttachElements(BimDocument document)
  33. {
  34. var bimObjects = document.BimObjects;
  35. var group = bimObjects.GroupBy(bim => bim.ElementType);
  36. Dictionary<string, List<BimObject>> dic = new Dictionary<string, List<BimObject>>();
  37. foreach (var collection in group)
  38. {
  39. dic[collection.Key + "s"] = collection.ToList();
  40. }
  41. Elements = dic;
  42. }
  43. public static MBIDocument CreateDocument(Document document, string param)
  44. {
  45. MBIDocument dto = new MBIDocument();
  46. JObject jObject = JObject.Parse(param);
  47. dto.MBIName = jObject.GetValueEx("MBIName");//待读取
  48. dto.ModelId = jObject.GetValueEx("ModelId");
  49. //dto.MBIName = "Pj1101010015";//待读取
  50. //dto.ModelId = "6d8642d9d92a11e98e2d2108fa0baa21";
  51. dto.PlanName = document.GetUseView()?.Name;
  52. return dto;
  53. }
  54. }
  55. }