Autodesk Revit Development
I serialized an XYZ point form a class (Points) from a container (Points and Tags) to a file.
public class Serialize_pack
{
public View_3D_Data v3ddata;
public Tag_Class tg;
}
through this Method
public static void serializeme(object classme)
{
string coor_file = constants.SenddDir() + constants.filename();
using (StreamWriter file = File.CreateText(coor_file))
{
JsonSerializer serializer = new JsonSerializer();
serializer.Serialize(file, classme);
}
}
and i got this results
{"Points":{"bboxmin":{"Z":-1000.0,"Y":-100.0,"X":-100.0},"bboxmax":{"Z":-0.1,"Y":100.0,"X":100.0}},"tg":{"eId":"666470","text":"coor: Kiss me"}}
on deserializing i got the results for all the points to a value of (0.0,0.0,0.0) which is a result of unable to parse read values to its propitiate type.
Deserializing Method
public static object deserializeme(string path)
{
Serialize_pack accquired = null;
using (StreamReader file = File.OpenText(path))
{
JsonSerializer serializer = new JsonSerializer();
accquired = (Serialize_pack)serializer.Deserialize(file, typeof(Serialize_pack));
}
return accquired;
}
I wish i could find a way a good way to convert and override this mess.
Edit: Exact Newton.JSon OutPut
{"Points":{"bboxmin":{"Z":-1000.0,"Y":-100.0,"X":-100.0},"bboxmax":{"Z":-0.1,"Y":100.0,"X":100.0},"sboxmin":{"Z":-10.277690406517843,"Y":-13.533464566929133,"X":-13.389107611548557},"sboxmax":{"Z":16.510826771653544,"Y":13.533464566929133,"X":13.389107611548557},"vorEyP":{"Z":30.114082470913921,"Y":34.471718543415037,"X":-7.7202528373680934},"vorFwD":{"Z":-0.57735026918962573,"Y":-0.57735026918962584,"X":0.57735026918962573},"vorUP":{"Z":0.816496580927726,"Y":-0.408248290463863,"X":0.40824829046386296},"v3dname":"Arch_Moustafa-GAJ-145834"},"Tags":{"eId":"666470","origin":{"Z":1154.5239372729186,"Y":1164.3934060532893,"X":-1119.6229882673815},"text":"coor: Kiss me","ledelbo":{"Z":1157.6807845880096,"Y":1163.9955344285622,"X":-1116.8640125770175}}}
Tag Class
public class Tag
{
public string eId;
public XYZ origin;
public string text;
public XYZ ledelbo;
public void getTagdata(View v)
{
///we need all the annotation to be sent.
/// do some stuff and cast the results on the public variables
}
}
Points Class
public class Points
{
public XYZ bboxmin;
public XYZ bboxmax;
public XYZ sboxmin;
public XYZ sboxmax;
public XYZ vorEyP;
public XYZ vorFwD;
public XYZ vorUP;
public string v3dname;
[JsonIgnore]
public View3D view;
public void get3dviewdata()
{
///we need all the points to be sent.
/// do some stuff and cast the results on the public variables
}
}