|
@@ -14,30 +14,18 @@ using JBIM;
|
|
using Newtonsoft.Json;
|
|
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Converters;
|
|
using Newtonsoft.Json.Converters;
|
|
using Newtonsoft.Json.Linq;
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
+using RevitToJBim.MBI;
|
|
|
|
|
|
namespace RevitToJBim.JsonConverter
|
|
namespace RevitToJBim.JsonConverter
|
|
{
|
|
{
|
|
public static class BimJsonUtil
|
|
public static class BimJsonUtil
|
|
{
|
|
{
|
|
- public static string Serializer(BimDocument document)
|
|
|
|
|
|
+ public static string Serializer(MBIDocument document)
|
|
{
|
|
{
|
|
JsonSerializerSettings jsetting = CreateDefaultSettings();
|
|
JsonSerializerSettings jsetting = CreateDefaultSettings();
|
|
- var bimObjects = document.BimObjects;
|
|
|
|
- var group = bimObjects.GroupBy(bim => bim.ElementType);
|
|
|
|
- Dictionary<string, List<BimObject>> dic = new Dictionary<string, List<BimObject>>();
|
|
|
|
- foreach (var collection in group)
|
|
|
|
- {
|
|
|
|
- dic[collection.Key + "s"] = collection.ToList();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- var documentObject = new {MBIName = "PjXXX_001", PlanName = "F1-saga", Elements = dic};
|
|
|
|
- //var serializer = JsonSerializer.Create(jsetting);
|
|
|
|
- //var jobject=JObject.FromObject(dic, serializer);
|
|
|
|
- //jobject.ToString();
|
|
|
|
- string dataStr =JsonConvert.SerializeObject(documentObject, jsetting);
|
|
|
|
|
|
+ string dataStr =JsonConvert.SerializeObject(document, jsetting);
|
|
return dataStr;
|
|
return dataStr;
|
|
}
|
|
}
|
|
-
|
|
|
|
private static JsonSerializerSettings CreateDefaultSettings()
|
|
private static JsonSerializerSettings CreateDefaultSettings()
|
|
{
|
|
{
|
|
JsonSerializerSettings jsetting = new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore };
|
|
JsonSerializerSettings jsetting = new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore };
|
|
@@ -48,30 +36,6 @@ namespace RevitToJBim.JsonConverter
|
|
jsetting.Converters.Add(new ParameterConverter());
|
|
jsetting.Converters.Add(new ParameterConverter());
|
|
return jsetting;
|
|
return jsetting;
|
|
}
|
|
}
|
|
- private static DocumentDto ConverToDto(BimDocument document)
|
|
|
|
- {
|
|
|
|
- DocumentDto dto = new DocumentDto();
|
|
|
|
- var bimObjects = document.BimObjects;
|
|
|
|
- var group = bimObjects.GroupBy(bim => bim.ElementType);
|
|
|
|
- Dictionary<string, List<BimObject>> dic = new Dictionary<string, List<BimObject>>();
|
|
|
|
- foreach (var collection in group)
|
|
|
|
- {
|
|
|
|
- dic[collection.Key + "s"] = collection.ToList();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- dto.MBIName = "PjXXX_001";//待读取
|
|
|
|
- dto.PlanName = "F1-saga";
|
|
|
|
- dto.Elements = dic;
|
|
|
|
- return dto;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- /// <summary>
|
|
|
|
- /// 项目传输数据结构
|
|
|
|
- /// </summary>
|
|
|
|
- public class DocumentDto
|
|
|
|
- {
|
|
|
|
- public string MBIName { get; set; }
|
|
|
|
- public string PlanName { get; set; }
|
|
|
|
- public Dictionary<string, List<BimObject>> Elements { get; set; }
|
|
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|