|
@@ -13,6 +13,7 @@ using System.Threading.Tasks;
|
|
|
using JBIM;
|
|
|
using Newtonsoft.Json;
|
|
|
using Newtonsoft.Json.Converters;
|
|
|
+using Newtonsoft.Json.Linq;
|
|
|
|
|
|
namespace RevitToJBim.JsonConverter
|
|
|
{
|
|
@@ -26,14 +27,16 @@ namespace RevitToJBim.JsonConverter
|
|
|
//jsetting.Converters.Add(new XYZConverter());
|
|
|
jsetting.Converters.Add(new StringEnumConverter());
|
|
|
jsetting.Converters.Add(new ParameterConverter());
|
|
|
- //var serializer = JsonSerializer.Create(jsetting);
|
|
|
- //JObject jobject = new JObject();
|
|
|
- //foreach (var collection in m_DataSource)
|
|
|
- //{
|
|
|
- // jobject.Add(collection.Key, JArray.FromObject(collection.Value, serializer));
|
|
|
- //}
|
|
|
+ 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();
|
|
|
+ //jobject.Add(collection.Key, JArray.FromObject(collection.Value, serializer));
|
|
|
+ }
|
|
|
//var settings = new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore };
|
|
|
- string dataStr = JsonConvert.SerializeObject(document.BimObjects, jsetting);
|
|
|
+ string dataStr = JsonConvert.SerializeObject(dic, jsetting);
|
|
|
return dataStr;
|
|
|
}
|
|
|
}
|