Revit c# export json

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all;
we are working on a plugin "revit system element database working with mongodb".
The project working on visual studio c# and we convert the revit element object directly to mongo we have a problem on converting the object to json format the error are blow.
as an alternative we tried to insert the element object directly to mongodb the export data is like the picture below.
how can we overcome the export to json issue?
thanks in advance
[JsonObject(MemberSerialization.OptOut)]
[Serializable]
public class ElementDataEntity
{
[JsonProperty]
public int ElementDataEntityId { get; set; }
[JsonProperty]
public int ElementId { get; set; }
[JsonProperty]
public String element { get; set; }
}
public void Execute(UIApplication uiapp)
{
mongoDbConnection mongoDbConnection = new mongoDbConnection();
//get all data
List<ElementDataEntity> elementDataEntitys= mongoDbConnection.GetAllElement();
Document doc = uiapp.ActiveUIDocument.Document;
Selection sel = uiapp.ActiveUIDocument.Selection;
Transaction ts = new Transaction(doc, "");
ts.Start();
Element elemPick = null;
Reference refelem = sel.PickObject(ObjectType.Element);
elemPick = doc.GetElement(refelem.ElementId);
ElementDataEntity elementDataEntity = new ElementDataEntity();
elementDataEntity.element = Newtonsoft.Json.JsonConvert.SerializeObject(elemPick);
elementDataEntity.ElementId = refelem.ElementId.IntegerValue;
elementDataEntity.ElementDataEntityId =1;
//insert revit element data
mongoDbConnection.insertDataMongoDb(elementDataEntity);
}
error : Error getting value from 'WorksharingCentralGUID' on 'Autodesk.Revit.DB.Document'.