private void RunScript(object x, object y, ref object A)
{
var field = new Grasshopper.Kernel.Types.GH_Field();
var elem = x as List<IGH_FieldElement>;
field.Elements.AddRange(elem);
Print(field.ToString()); //returns a valid field.
var name = "TEST";
try
{
var arc = new GH_Archive();
var res = arc.AppendObject(field, name);
var xml = arc.Serialize_Xml();
var field2 = new Grasshopper.Kernel.Types.GH_Field();
var arc2 = new GH_Archive();
res &= arc2.Deserialize_Xml(xml);
res &= arc2.ExtractObject(field2, name);
A = res;
Print(field2.ToString()); // returns an empty field.
}
catch(Exception e)
{
Print(e.ToString());
}
}
I need to recover a GH_Field from xml but its deserialization doesn’t work or I don’t know how. I tried with the Data Input and Data Output components and it doesn’t work either, so it seems to be a bug.
GH_Field serialization issue.gh (5.7 KB)