diff --git a/apps/rhino-compute-server/Endpoints/GrasshopperEndpoints.cs b/apps/rhino-compute-server/Endpoints/GrasshopperEndpoints.cs index 832cbefc7..b5e68032c 100644 --- a/apps/rhino-compute-server/Endpoints/GrasshopperEndpoints.cs +++ b/apps/rhino-compute-server/Endpoints/GrasshopperEndpoints.cs @@ -73,7 +73,29 @@ public class NodePenSolutionData : Base public NodePenSolutionDataManifest Manifest { get; set; } = new NodePenSolutionDataManifest(); [JsonProperty("values")] - public Dictionary> Values { get; set; } = new Dictionary>(); + public NodePenSolutionDataSolutionValues Values { get; set; } = new NodePenSolutionDataSolutionValues(); + + public void ToDto() + { + foreach (var node in Values.Values) + { + foreach (var port in node.Values) + { + foreach (var branch in port.Values) + { + foreach (var entry in branch) + { + entry.ToDto(); + } + } + } + } + } + } + + public class NodePenSolutionDataSolutionValues : Dictionary> + { + } public class NodePenSolutionDataManifest : Base @@ -249,7 +271,7 @@ public Response SolveGrasshopperDocument(NancyContext context) solutionData["Id"] = requestData.SolutionId; solutionData.Manifest.StreamObjectIds.Add(objectId); - solutionData.Values = new Dictionary>(); + solutionData.ToDto(); return Response.AsJson(solutionData); } diff --git a/packages/converters/models/NodePenDocument.cs b/packages/converters/models/NodePenDocument.cs index 2bf828cce..c93da3215 100644 --- a/packages/converters/models/NodePenDocument.cs +++ b/packages/converters/models/NodePenDocument.cs @@ -142,7 +142,6 @@ public class NodePenDataTree : Dictionary> public class NodePenDataTreeValue : Base { - [JsonProperty("type")] public string Type { get; set; } @@ -154,6 +153,17 @@ public class NodePenDataTreeValue : Base public dynamic Geometry { get; set; } = null; + public void ToDto() + { + Value = null; + Geometry = null; + } + + public bool ShouldSerializeGeometry() + { + return Geometry != null; + } + public double UnwrapAsDouble() { return Convert.ToDouble(this["Value"]); @@ -166,4 +176,24 @@ public int UnwrapAsInteger() } + public class NodePenDataTreeDto : Dictionary> + { + + } + + public class NodePenDataTreeValueDto + { + [JsonProperty("type")] + public string Type { get; set; } + + [JsonProperty("description")] + public string Description { get; set; } + + public NodePenDataTreeValueDto(NodePenDataTreeValue value) + { + Type = value.Type; + Description = value.Description; + } + } + } \ No newline at end of file